Here is the scenario that needs to be implemented:
- An API call is made which returns a response containing an array of objects.
- The objects are then mapped to another array of objects.
- For each item in this new array, another API call needs to be made.
- The response from the second call should update a value in each object created in step 2.
- An observable containing the array of updated objects from step 4 should be returned.
Progress so far includes the following code:
public getWishlist(receiver: Person): Observable<Wish[]> {
return this.http$.get<IWishlistResponse[]>(environment.apiUrl + 'wishlist/' + receiver.id).pipe(
map((response) => {
let wishes: Wish[] = [];
response[0].wishes.forEach((wish) => {
wishes.push(new Wish(
wish._id,
wish.title,
wish.price,
null,
wish.url
));
});
return wishes;
}),
????
);
}
The 'wishes' logged in console.log within the subscribe function of forkJoin are the desired values to be returned in the observable. However, they are not being captured by the observable. What operator should be used instead of 'tap' in order to include the results of the forkJoin pipe in the returned observable?