When I try to subscribe inside map
function, the observable doesn't wait for inner subscriptions to execute.
I have the folowwing :
return this.http.get(url).map((project)=>{
// replace pilot id by pilot object
this.UserService.retrieveObject(project.pilot).subscribe(pilot => {
project.pilot = pilot,
})
//replace owner id by owner object
this.UserService.retrieveObject(project.owner).subscribe(owner => {
project.owner = owner,
})
return project;
});
the returning project
object contains owner, and pilot ids instead of objects because it doesn't wait for subscriptions.
How to make so that observable wait for all inner subscriptions to finish ?