I am using RXJS 6 together with Angular 6 HttpClient and I am trying to execute two http calls sequentially.
- I need to return the result of the first call only.
- The first call must be issued before the second.
I thought of using the tap method as follows:
someMethod(items: Item[]): Observable<Item[]> {
const one = this.http.put<{ items: Item[] }>('urlOne', items);
const two = this.http.put<void>('urlTwo', items);
return one.pipe(
mergeMap((res)=> res.items),
tap(two)
);
}
Is there a better way? If so how?