Is it possible to efficiently make sequential API calls using RxJs? The challenge lies in the fact that the first Observable emits an array, and for each item in this array, a custom URL should be set for the next call. Additionally, certain conditions need to be checked in the second call before returning an Observable.
I'm struggling with setting the URL for each element of the array as it changes. Can anyone provide guidance on how to achieve this?
private fetchData(): Observable<boolean> {
return this.service
.getItems()
.pipe(
map((response) => response.items),
mergeMap((result) => {
result.map((order) =>
this.orderService.setCustomUrl(order.number)
);
return this.orderService.getItems().pipe(
mergeMap((response) => {
if (response.items.some((item) => item.number === this.model.number)) {
return of(true);
} else {
return of(false);
}
}),
);
})
);
}