Using RxJS v6 is challenging to retrieve data from sub collection for every item in the loop. There is no way to iterate throw array that is retrieved from HTTP call. Merge
Although kvetis's answer can work for you here is what I implemented, just posting it because I found it interesting to solve.
public getCombinedData(): Observable {
return this.getMultipleRelationData()
.pipe(
mergeMap((result: any) => {
let allIds = result.contact.map(id => this.getSingleData(id._id));
return forkJoin(...allIds).pipe(
map((idDataArray) => {
result.contact.forEach((eachContact, index) => {
eachContact.relationship = idDataArray[index];
})
return result;
})
)
})
);
}
Here is an example solution for your question, I have made dummy Observables. https://stackblitz.com/edit/angular-tonn5q?file=src%2Fapp%2Fapi-calls.service.ts