Reputation: 147
Currently I have the following request:
return this.registrationService.registratePerson(data).pipe(
switchMap(
res => {
return this.registrationService.sendPassportScan(this.form.value.passportScanCopyFile, res.AisUserIsn);
}
)
);
The second request makes use of the result obtained in the first one, that's something that I need but the problem with it is that now it returns what comes from the second request (the inner one). Is it possible somehow with the help of rxjs operators to make it return an observable containing fields from the inner request as well as those from the outer one?
In the application the 5th version of rxjs is used.
Upvotes: 1
Views: 422
Reputation: 99
concatMap may help you in this case
https://www.learnrxjs.io/operators/transformation/concatmap.html
Example https://angular-academy.com/rxjs-switchmap-concatmap-mergemap-exhaustmap/#concatmap
Upvotes: 0
Reputation: 14689
Sure. Something like this:
return this.registrationService.registratePerson(data).pipe(
switchMap(
res => forkJoin(
of(res),
this.registrationService.sendPassportScan(/* relevant args */),
)))
(The resulting stream will contain a 2 element array).
Upvotes: 1