Using the flatMap operator to create sequential HTTP calls
The days of using Promises were awesome. It's not that those days are gone, but we as developers surely prefer Observables over Promises for a lot of reasons. One of the things I really like about Promises is that you can chain Promises to do things such as sequential HTTP calls. In this recipe, you'll learn how to do the same with Observables using the flatMap
operator.
Getting ready
The project that we are going to work with resides in chapter05/start_here/using-flatmap-operator
, inside the cloned repository.
- Open the project in VS Code.
- Open the Terminal and run
npm install
to install the dependencies of the project. - Once done, run
ng serve -o
.This should open the app in a new browser tab, and you should see something like this:
The app right now seems perfect, actually. Nothing...