Move api call to a service