I have 2 API calls -- the second call uses something the first call returns. With promises this was easy:
myService.findAll()
// First call
.then(response => {
return myService.findSpecific(response.something);
})
.then(response => {
// result from second API call
});
How would I do this using observables?
You can leverage the flatMap
operator this way:
myService.findAll()
// First call
.flatMap(response => {
return myService.findSpecific(response.something);
}).subscribe(response => {
// result from second API call
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With