First one returns an array of objects . Every object has a unique user id which I need in order to call the second service.
this._vendorService.getAllPickupLoc().subscribe(val => {
val.forEach(element => {
this.finalObject = element;
this._vendorService.getVendorUserInfo(element.id).subscribe(res => {
this.finalObject["userInfo"] = res;
this.finalArray.push(this.finalObject);
});
});
});
While it works fine, there are two drawbacks to the code above. 1. It’s starting to look like callback hell. 2. I’d have to handle the disposal of every subscription by myself.