I have a subscription that relies on the outcome of a previous subscription. I am utilizing forkJoin to avoid nesting them:
this.service.service1().pipe(
flatMap((res1) => this.service.service2(res1))
).subscribe((res2) => {
// Perform actions with res2.
});
The challenge is that I need to alter the data before calling the second subscription. My goal is to do something along the lines of:
this.service.service1().pipe(
flatMap((res1) => {
// Modify res1 data here.
// Make 2nd Api Call
this.service.service2(res1)
})
).subscribe((res2) => {
// Do something with res2.
});
Is there a different operator/syntax I should use to accomplish this or can I tweak this approach?