Axios-Retry
If you have been coding in javascript for a while, you'd probably have known about Axios. It is a famous JS library for making HTTP request. Whether you are back-end or front-end developer, Axios is essential to access API services.
In this post, I'm going to show how to equip Axios with retry capability i.e resend HTTP request when server doesn't answer.
Axios plugin that intercepts failed requests and retries them whenever possible.
Weekly Downloads - 1,896,493
Last Published - 2 Months ago
Configurations provided by the package.
retries |
|
| The number of times to retry before failing. 1 = One retry after first failure |
retryCondition |
|
| A callback to further control if a request should be retried. By default, it retries if it is a network error or a 5xx error on an idempotent request (GET, HEAD, OPTIONS, PUT or DELETE). |
shouldResetTimeout |
| false | Defines if the timeout should be reset between retries |
retryDelay |
|
| A callback to further control the delay in milliseconds between retried requests. By default there is no delay between retries. Another option is exponentialDelay (Exponential Backoff). The function is passed |
onRetry |
|
| A callback to notify when a retry is about to occur. Useful for tracing. By default nothing will occur. The function is passed |
Hope this helps 👍
No comments:
Post a Comment
If you have any doubts, Please let me know