Gathering detailed insights and metrics for axios-retry
Gathering detailed insights and metrics for axios-retry
Gathering detailed insights and metrics for axios-retry
Gathering detailed insights and metrics for axios-retry
Axios plugin that intercepts failed requests and retries them whenever possible
npm install axios-retry
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
1,896 Stars
263 Commits
167 Forks
30 Watching
2 Branches
45 Contributors
Updated on 22 Nov 2024
TypeScript (99.9%)
Shell (0.1%)
Cumulative downloads
Total Downloads
Last day
-4.4%
607,305
Compared to previous day
Last week
8.2%
3,485,138
Compared to previous week
Last month
8.4%
13,799,281
Compared to previous month
Last year
25.6%
143,030,692
Compared to previous year
Axios plugin that intercepts failed requests and retries them whenever possible.
1npm install axios-retry
1// CommonJS 2// const axiosRetry = require('axios-retry').default; 3 4// ES6 5import axiosRetry from 'axios-retry'; 6 7axiosRetry(axios, { retries: 3 }); 8 9axios.get('http://example.com/test') // The first request fails and the second returns 'ok' 10 .then(result => { 11 result.data; // 'ok' 12 }); 13 14// Exponential back-off retry delay between requests 15axiosRetry(axios, { retryDelay: axiosRetry.exponentialDelay }); 16 17// Liner retry delay between requests 18axiosRetry(axios, { retryDelay: axiosRetry.linearDelay() }); 19 20// Custom retry delay 21axiosRetry(axios, { retryDelay: (retryCount) => { 22 return retryCount * 1000; 23}}); 24 25// Works with custom axios instances 26const client = axios.create({ baseURL: 'http://example.com' }); 27axiosRetry(client, { retries: 3 }); 28 29client.get('/test') // The first request fails and the second returns 'ok' 30 .then(result => { 31 result.data; // 'ok' 32 }); 33 34// Allows request-specific configuration 35client 36 .get('/test', { 37 'axios-retry': { 38 retries: 0 39 } 40 }) 41 .catch(error => { // The first request fails 42 error !== undefined 43 });
Note: Unless shouldResetTimeout
is set, the plugin interprets the request timeout as a global value, so it is not used for each retry but for the whole request lifecycle.
Name | Type | Default | Description |
---|---|---|---|
retries | Number | 3 | The number of times to retry before failing. 1 = One retry after first failure |
retryCondition | Function | isNetworkOrIdempotentRequestError | 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 | Boolean | false | Defines if the timeout should be reset between retries |
retryDelay | Function | function noDelay() { return 0; } | 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) or linearDelay . The function is passed retryCount and error . |
onRetry | Function | function onRetry(retryCount, error, requestConfig) { return; } | A callback to notify when a retry is about to occur. Useful for tracing and you can any async process for example refresh a token on 401. By default nothing will occur. The function is passed retryCount , error , and requestConfig . |
onMaxRetryTimesExceeded | Function | function onMaxRetryTimesExceeded(error, retryCount) { return; } | After all the retries are failed, this callback will be called with the last error before throwing the error. |
validateResponse | Function | null | null | A callback to define whether a response should be resolved or rejected. If null is passed, it will fallback to the axios default (only 2xx status codes are resolved). |
Clone the repository and execute:
1npm test
git clone https://github.com/softonic/axios-retry.git
git checkout -b feature/my-new-feature
git commit -am 'Added some feature'
npm run build
git push origin my-new-feature
No vulnerabilities found.
Reason
security policy file detected
Details
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
6 existing vulnerabilities detected
Details
Reason
Found 6/19 approved changesets -- score normalized to 3
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More