I'm still learning RxJs, and I'm trying to use concatMap() to NOT use nested subscriptions. I want the first call to run and then delay for a second or two (creating a database record before the second request) before running the second request. I also want to add error handling to each request specifically so I can catch errors for them individually.
So far, I have something that runs request 1, delays, and then runs request 2.
return this.request_1(postData).pipe(
concatMap(res => of(res).pipe( delay( 2000 ) )),
concatMap(res => this.request_2(parseInt(data.id), parseInt(model['_id'])) )
);
What I'm wondering is -
- can I use something like catchError() on each request?
- is this correct if I want request 1 to complete before the second request runs?
Thanks!