I have a function named fetchSeviceProviders which will return me a list of service providers and let me set the logo of the service providers by calling another service. I have achieved this by using two subscriptions.
At first subscription, I am getting the list. Then I am mapping it and calling the fetchServiceProviderLogo by all service providers' id.
Can this be done with one subscription? Is my method OK? If not, what is the problem? How can I do this by some rxjs operators?
I tried map and flatMap operator but couldn't get a clue.
fetchServiceProviders ()
{
this.subscribers.fetchServiceProvidersLogoSub = this.serviceProviderService.fetchServiceProviders( new Map() ).subscribe(
data =>
{
this.providers = data._embedded.serviceProviders;
this.providers.map(
provider =>
{
this.subscribers.fetchServiceProvidersLogoSub =
this.serviceProviderService.fetchServiceProviderLogo( { 'id': provider.id } ).subscribe(
logo =>
{
this.createIndividualLogoFromBlob( provider, logo );
}
);
}
);
}
)
}