Retrying failed HTTP calls with RxJS
In this recipe, you’re going to learn how to retry HTTP calls smartly with RxJS operators. We’re going to use a technique called the exponential backoff technique. This means that we retry the HTTP calls but with each next call having a delay more than the previous time for the attempt, and we stop after several maximum tries. Sounds exciting? Let’s get into it.
Getting ready
The app that we are going to work with resides in start/apps/chapter05/rx-retry-http-calls
inside the cloned repository:
- Open the code repository in your code editor.
- Open the terminal, navigate to the code repository directory, and run the following command to serve the project with the backend server:
npm run serve rx-retry-http-calls with-server
This should open the app in a new browser tab, and you should see the following:
Figure 5.14: The rx-retry-http-calls running on http://localhost.4200
...