天天看点

[RxJS] How To get the results of two HTTP requests made in sequence

<code>switchMap</code> can chain two HTTP requests together, creating one request based on the results of the first request.

But the result observable did not have the data of the first request, instead it only had access to the data of the second HTTP request.

If we would like to have both the data of the first HTTP request and deliver it together with the data of the second request, we could use a selector function (notice the second argument passed to <code>switchMap</code>):

Other example: