Choosing the appropriate operator depends on whether you prefer to send the two requests concurrently or sequentially.
If you already have take(1)
, then you can opt for either switchMap
or mergeMap
since it will only emit once regardless of the choice.
For parallel request sending:
return this.upload(myForm).pipe(
take(1),
switchMap(res => {
...
return forkJoin([
this.http.post<IRresponse<object>>(environment.api + EndPoint.CreateUser, body),
this.http.post<IRresponse<object>>(environment.api + EndPoint.CreateUser, body),
]);
}),
);
For sequential request sending:
return this.upload(myForm).pipe(
take(1),
switchMap(res => {
...
return concat(
this.http.post<IRresponse<object>>(environment.api + EndPoint.CreateUser, body),
this.http.post<IRresponse<object>>(environment.api + EndPoint.CreateUser, body),
);
}),
);