Suppose I want to hide the work with HttpClient
behind the service, and then inject it into a specific component and pull methods so that all the details are hidden from the component.
The problem is asynchronous HttpClient
. For example, I pull get and the method flies farther, returning undefined
.
Well, for example, the component accesses the service service.GetCars (), which pulls the API inside itself and sends a get request, how can I get this data inside the component?
Should I return Observable, and the user of this service execute subscribe
and remap the data? Well, in my opinion it is not quite right.