I have an api that returns me an Array<string>
of ids, given an original id (one to many). I need to make an http request on each of these ids to get back the associated data from the api. I cannot figure out how to take the Observable<string[]>
and map it to the Observable<DataType[]>
.
I would like to keep the original observable and use operators to get the desired outcome if at all possible.
Piping the map
operator doesn't work in this situation due to the fact that the only item in the observable is the array.
Here's some example code that is similar to the implementation I am attempting.
getIds = (originalId: string) => {
return this.http.get<string[]>(url);
}
getDataFromIds = (originalId: string): Observable<DataType[]> => {
const ids$ = this.getIds(originalId);
// Make http calls for each of the items in the array.
result = ids$.pipe();
return result;
}