{"_id":"@audc/retry-axios","_rev":"8-68366ef9e95efe8ae6d953dae7c3fd17","name":"@audc/retry-axios","dist-tags":{"latest":"3.2.6"},"versions":{"3.2.0":{"name":"@audc/retry-axios","version":"3.2.0","keywords":["axios","retry"],"author":{"name":"Justin Beckwith"},"license":"Apache-2.0","_id":"@audc/retry-axios@3.2.0","maintainers":[{"name":"bivas6","email":"yaakov.bivas@audiocodes.com"},{"name":"orgads","email":"orgads@gmail.com"}],"homepage":"https://github.com/audiocodes/retry-axios#readme","bugs":{"url":"https://github.com/audiocodes/retry-axios/issues"},"c8":{"exclude":["build/test","dist"]},"xo":{"rules":{"@typescript-eslint/prefer-nullish-coalescing":"off","@typescript-eslint/consistent-type-definitions":"off"}},"dist":{"shasum":"09fe0abe5d059a5037c16a091c4a902c5dafcb86","tarball":"https://registry.npmjs.org/@audc/retry-axios/-/retry-axios-3.2.0.tgz","fileCount":6,"integrity":"sha512-lq/caoMCtaHlq8hLDV0LQ7sUPcJUB9jweCa/RJk/nkZOR9KlCJ0xughgx53EBcECPAPL9y/JYCnhQ4KY6rLzVQ==","signatures":[{"sig":"MEYCIQCamG9pLS1q7mYV+Oy89VHwZNP5FTh//i4ZgxR+a9k3AwIhAIhchPljDVsFFp+op2OfTt/6OvRuqIUBzC15Hid4pzcw","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36957},"type":"module","types":"./build/src/index.d.ts","engines":{"node":">=18"},"exports":"./build/src/index.js","gitHead":"ca9bb0965c51a97680bbd810dd3b24bb3651ab85","scripts":{"fix":"xo --prettier --fix","lint":"xo --prettier","test":"c8 mocha build/test","compile":"tsc -p .","pretest":"npm run compile","license-check":"jsgl --local ."},"_npmUser":{"name":"orgads","email":"orgads@gmail.com"},"repository":{"url":"git+https://github.com/audiocodes/retry-axios.git","type":"git"},"_npmVersion":"10.8.1","description":"Retry HTTP requests with Axios.","directories":{},"_nodeVersion":"20.14.0","_hasShrinkwrap":false,"devDependencies":{"c8":"^10.0.0","xo":"^0.58.0","nock":"^13.3.0","axios":"^1.2.1","mocha":"^10.2.0","sinon":"^18.0.0","typescript":"~5.4.2","@types/node":"^20.0.0","@types/mocha":"^10.0.1","@types/sinon":"^17.0.0","semantic-release":"^24.0.0","js-green-licenses":"^4.0.0"},"peerDependencies":{"axios":"*"},"_npmOperationalInternal":{"tmp":"tmp/retry-axios_3.2.0_1718289736246_0.10164537478341318","host":"s3://npm-registry-packages"}},"3.2.1":{"name":"@audc/retry-axios","version":"3.2.1","keywords":["axios","retry"],"author":{"name":"Justin Beckwith"},"license":"Apache-2.0","_id":"@audc/retry-axios@3.2.1","maintainers":[{"name":"bivas6","email":"yaakov.bivas@audiocodes.com"},{"name":"orgads","email":"orgads@gmail.com"}],"homepage":"https://github.com/audiocodes/retry-axios#readme","bugs":{"url":"https://github.com/audiocodes/retry-axios/issues"},"c8":{"exclude":["build/test","dist"]},"xo":{"rules":{"@typescript-eslint/prefer-nullish-coalescing":"off","@typescript-eslint/consistent-type-definitions":"off"}},"dist":{"shasum":"287a433e075090b94c21af30f6206444ce6d5f3b","tarball":"https://registry.npmjs.org/@audc/retry-axios/-/retry-axios-3.2.1.tgz","fileCount":6,"integrity":"sha512-j86xHjhAO8ibO6O/be8gJzyeb5xJThrYsxT4lbWkdN8vUYCUbOH5y6GAhwNMZOBXcPQ/4wK3Y5jM+g61Jr1zgA==","signatures":[{"sig":"MEYCIQCBkxIpNfSaOkyiw/1onJW6bh4XBhHx2gw/XP8HHCjBqQIhAPnUaFMr5kUYQzyBC5TWfU5ns+iD7X/DhnWucGHpKfRQ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36958},"type":"module","types":"./build/src/index.d.ts","engines":{"node":">=18"},"exports":"./build/src/index.js","gitHead":"c13fa35b41cfcfaddf9497e8f2b5fd784e3d7367","scripts":{"fix":"xo --prettier --fix","lint":"xo --prettier","test":"c8 mocha build/test","compile":"tsc -p .","pretest":"npm run compile","license-check":"jsgl --local ."},"_npmUser":{"name":"orgads","email":"orgads@gmail.com"},"repository":{"url":"git+https://github.com/audiocodes/retry-axios.git","type":"git"},"_npmVersion":"10.8.1","description":"Retry HTTP requests with Axios.","directories":{},"_nodeVersion":"20.14.0","_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.2","xo":"^0.58.0","nock":"^13.5.4","axios":"^1.7.2","mocha":"^10.4.0","sinon":"^18.0.0","typescript":"~5.4.5","@types/node":"^20.14.2","@types/mocha":"^10.0.6","@types/sinon":"^17.0.3","semantic-release":"^24.0.0","js-green-licenses":"^4.0.0"},"peerDependencies":{"axios":"*"},"_npmOperationalInternal":{"tmp":"tmp/retry-axios_3.2.1_1718291393905_0.1860939830795909","host":"s3://npm-registry-packages"}},"3.2.2":{"name":"@audc/retry-axios","version":"3.2.2","keywords":["axios","retry"],"author":{"name":"Justin Beckwith"},"license":"Apache-2.0","_id":"@audc/retry-axios@3.2.2","maintainers":[{"name":"bivas6","email":"yaakov.bivas@audiocodes.com"},{"name":"orgads","email":"orgads@gmail.com"}],"homepage":"https://github.com/audiocodes/retry-axios#readme","bugs":{"url":"https://github.com/audiocodes/retry-axios/issues"},"c8":{"exclude":["build/test","dist"]},"xo":{"rules":{"@typescript-eslint/prefer-nullish-coalescing":"off","@typescript-eslint/consistent-type-definitions":"off"}},"dist":{"shasum":"8ce8fe4fbf431c9f37b93d322fcb5d44183cfb55","tarball":"https://registry.npmjs.org/@audc/retry-axios/-/retry-axios-3.2.2.tgz","fileCount":6,"integrity":"sha512-GvxidF3TIEVHwDKuyo/n77wyse+FNoNAYBl8+JsuOU2yxh0aC1vH2Gp1zhr2F3jBgAFLWp65ul7WgZTxtT+niA==","signatures":[{"sig":"MEUCIQD0VOmMpzjH4dRLmSzEV/ADb/5SJHHVXbewErVYBdtQ9AIgZMPsRPoD2hR+WlbpfvFrfbfITpJOC6DxVC8BcdZ/jkI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":38338},"main":"dist/index.js","type":"commonjs","types":"./build/src/index.d.ts","source":"src/index.ts","engines":{"node":">=18"},"gitHead":"718ceb73f6c83d3ee8f5c4f5c26b2c9bbf3b5fc7","scripts":{"fix":"xo --prettier --fix","lint":"xo --prettier","test":"c8 mocha build/test","compile":"tsc -p .","pretest":"npm run compile","license-check":"jsgl --local ."},"_npmUser":{"name":"orgads","email":"orgads@gmail.com"},"repository":{"url":"git+https://github.com/audiocodes/retry-axios.git","type":"git"},"_npmVersion":"10.8.1","description":"Retry HTTP requests with Axios.","directories":{},"_nodeVersion":"20.14.0","_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.2","xo":"^0.58.0","nock":"^13.5.4","axios":"^1.7.2","mocha":"^10.4.0","sinon":"^18.0.0","typescript":"~5.4.5","@types/node":"^20.14.2","@types/mocha":"^10.0.6","@types/sinon":"^17.0.3","semantic-release":"^24.0.0","js-green-licenses":"^4.0.0"},"peerDependencies":{"axios":"*"},"_npmOperationalInternal":{"tmp":"tmp/retry-axios_3.2.2_1718292836173_0.34400532602448464","host":"s3://npm-registry-packages"}},"3.2.3":{"name":"@audc/retry-axios","version":"3.2.3","keywords":["axios","retry"],"author":{"name":"Justin Beckwith"},"license":"Apache-2.0","_id":"@audc/retry-axios@3.2.3","maintainers":[{"name":"bivas6","email":"yaakov.bivas@audiocodes.com"},{"name":"orgads","email":"orgads@gmail.com"}],"homepage":"https://github.com/audiocodes/retry-axios#readme","bugs":{"url":"https://github.com/audiocodes/retry-axios/issues"},"c8":{"exclude":["build/test","dist"]},"xo":{"rules":{"@typescript-eslint/prefer-nullish-coalescing":"off","@typescript-eslint/consistent-type-definitions":"off"}},"dist":{"shasum":"7044fa37477ce76411679d6b15086d1f547ce38a","tarball":"https://registry.npmjs.org/@audc/retry-axios/-/retry-axios-3.2.3.tgz","fileCount":6,"integrity":"sha512-9/rcXJ0JUCUfokZ/vGtJUO+aS4lONHjhcehSVdm4+hHAZZknfeBVd1dBAVjPJpyv94iQbMS3Reibf0zgllAd9Q==","signatures":[{"sig":"MEUCIEV2jJZMKDKQ70fNWzTQc/vUW0WNf8KmfBVeiFJmp7/2AiEA7VhruCF/mXK8iCFD2i8sePHGcYmynQt0CpJvJ6bOj1s=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":38345},"main":"./build/src/index.js","type":"commonjs","types":"./build/src/index.d.ts","source":"src/index.ts","engines":{"node":">=18"},"gitHead":"de5e346218320cbe9c85ad0f8e4f7207979bdabb","scripts":{"fix":"xo --prettier --fix","lint":"xo --prettier","test":"c8 mocha build/test","compile":"tsc -p .","pretest":"npm run compile","license-check":"jsgl --local ."},"_npmUser":{"name":"orgads","email":"orgads@gmail.com"},"repository":{"url":"git+https://github.com/audiocodes/retry-axios.git","type":"git"},"_npmVersion":"10.8.1","description":"Retry HTTP requests with Axios.","directories":{},"_nodeVersion":"20.14.0","_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.2","xo":"^0.58.0","nock":"^13.5.4","axios":"^1.7.2","mocha":"^10.4.0","sinon":"^18.0.0","typescript":"~5.4.5","@types/node":"^20.14.2","@types/mocha":"^10.0.6","@types/sinon":"^17.0.3","semantic-release":"^24.0.0","js-green-licenses":"^4.0.0"},"peerDependencies":{"axios":"*"},"_npmOperationalInternal":{"tmp":"tmp/retry-axios_3.2.3_1718293254456_0.7093589362374659","host":"s3://npm-registry-packages"}},"3.2.4":{"name":"@audc/retry-axios","version":"3.2.4","keywords":["axios","retry"],"author":{"name":"Justin Beckwith"},"license":"Apache-2.0","_id":"@audc/retry-axios@3.2.4","maintainers":[{"name":"bivas6","email":"yaakov.bivas@audiocodes.com"},{"name":"orgads","email":"orgads@gmail.com"}],"homepage":"https://github.com/audiocodes/retry-axios#readme","bugs":{"url":"https://github.com/audiocodes/retry-axios/issues"},"c8":{"exclude":["build/test","dist"]},"dist":{"shasum":"a8220c2b18480d0472d41bd04d6e5e29cb4087bd","tarball":"https://registry.npmjs.org/@audc/retry-axios/-/retry-axios-3.2.4.tgz","fileCount":6,"integrity":"sha512-XjqPXdxs8imfjxDLswh70mu1onmqd6tl+nRw67ixYuJk2Kom9fS2pXw/qe4BpMlmVTqsZmKL/qYJCDJxTyYjLg==","signatures":[{"sig":"MEYCIQDmb/aUDTP88UGnyPL3OSYdutbRaK/UlRDH3PQ3Mnl+pAIhAMB+DIoI5T6fSmSn4PdamrijlQxDJQkTwo7Wa79I233q","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":38697},"main":"./build/src/index.js","type":"commonjs","types":"./build/src/index.d.ts","source":"src/index.ts","engines":{"node":">=18"},"gitHead":"7d17940beaa1b4bdddbd1a51d15aa392c09faa29","scripts":{"fix":"biome check --write .","lint":"biome check .","test":"c8 mocha build/test","compile":"tsc -p .","pretest":"npm run compile","license-check":"jsgl --local ."},"_npmUser":{"name":"orgads","email":"orgads@gmail.com"},"repository":{"url":"git+https://github.com/audiocodes/retry-axios.git","type":"git"},"_npmVersion":"10.8.2","description":"Retry HTTP requests with Axios.","directories":{},"_nodeVersion":"22.5.1","_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.2","nock":"^13.5.4","axios":"^1.7.2","mocha":"^10.4.0","sinon":"^19.0.0","typescript":"~5.6.0","@types/node":"^20.14.2","@types/mocha":"^10.0.6","@types/sinon":"^17.0.3","@biomejs/biome":"^1.8.3","semantic-release":"^24.0.0","js-green-licenses":"^4.0.0"},"peerDependencies":{"axios":"*"},"_npmOperationalInternal":{"tmp":"tmp/retry-axios_3.2.4_1728850475552_0.5469341407294113","host":"s3://npm-registry-packages"}},"3.2.5":{"name":"@audc/retry-axios","version":"3.2.5","keywords":["axios","retry"],"author":{"name":"Justin Beckwith"},"license":"Apache-2.0","_id":"@audc/retry-axios@3.2.5","maintainers":[{"name":"bivas6","email":"yaakov.bivas@audiocodes.com"},{"name":"orgads","email":"orgads@gmail.com"}],"homepage":"https://github.com/audiocodes/retry-axios#readme","bugs":{"url":"https://github.com/audiocodes/retry-axios/issues"},"c8":{"exclude":["build/test","dist"]},"dist":{"shasum":"b8f525245e97eb60930ce52f69b610ee89806949","tarball":"https://registry.npmjs.org/@audc/retry-axios/-/retry-axios-3.2.5.tgz","fileCount":6,"integrity":"sha512-lLnBKIqGBX2/9JsP17YEE7PwfFpXdi1AwSbMp7OhqsEY+GVROTXqj3YADqTGmS/7q00EScKnSnWyBULl3ZesZw==","signatures":[{"sig":"MEQCIE/iLtSEVA48R+WUoU+jrSi4kH5ZRsbmHZUQIkKs4pZUAiARlQMLaZMq+SmvG8nto+tNISfjeKIKaHYRdAiH4CeuTA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":37426},"main":"./build/src/index.js","type":"module","types":"./build/src/index.d.ts","source":"src/index.ts","engines":{"node":">=18"},"gitHead":"7d17940beaa1b4bdddbd1a51d15aa392c09faa29","scripts":{"fix":"biome check --write .","lint":"biome check .","test":"c8 mocha build/test","compile":"tsc -p .","pretest":"npm run compile","license-check":"jsgl --local ."},"_npmUser":{"name":"orgads","email":"orgads@gmail.com"},"repository":{"url":"git+https://github.com/audiocodes/retry-axios.git","type":"git"},"_npmVersion":"10.8.2","description":"Retry HTTP requests with Axios.","directories":{},"_nodeVersion":"22.5.1","_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.2","nock":"^13.5.4","axios":"^1.7.2","mocha":"^10.4.0","sinon":"^19.0.0","typescript":"~5.6.0","@types/node":"^20.14.2","@types/mocha":"^10.0.6","@types/sinon":"^17.0.3","@biomejs/biome":"^1.8.3","semantic-release":"^24.0.0","js-green-licenses":"^4.0.0"},"peerDependencies":{"axios":"*"},"_npmOperationalInternal":{"tmp":"tmp/retry-axios_3.2.5_1728851514123_0.6232874093787131","host":"s3://npm-registry-packages"}},"3.2.6":{"name":"@audc/retry-axios","version":"3.2.6","description":"Retry HTTP requests with Axios.","type":"module","source":"src/index.ts","main":"./build/src/index.js","types":"./build/src/index.d.ts","engines":{"node":">=18"},"repository":{"type":"git","url":"git+https://github.com/audiocodes/retry-axios.git"},"scripts":{"fix":"biome check --write .","lint":"biome check .","compile":"tsc -p .","test":"vitest run --coverage","test:watch":"vitest watch","license-check":"jsgl --local ."},"keywords":["axios","retry"],"author":{"name":"Justin Beckwith"},"license":"Apache-2.0","peerDependencies":{"axios":"*"},"devDependencies":{"@biomejs/biome":"^1.9.4","@types/node":"^22.15.30","@vitest/coverage-v8":"^3.2.2","axios":"^1.9.0","c8":"^10.1.3","js-green-licenses":"^4.0.0","nock":"^13.5.6","p-defer":"^4.0.1","semantic-release":"^24.2.5","typescript":"~5.8.3","unplugin-swc":"^1.5.4","vitest":"^3.2.2"},"c8":{"exclude":["build/test","dist"]},"_id":"@audc/retry-axios@3.2.6","gitHead":"be503720c597fac3f4e78b7c07e5012e63407b8a","bugs":{"url":"https://github.com/audiocodes/retry-axios/issues"},"homepage":"https://github.com/audiocodes/retry-axios#readme","_nodeVersion":"22.16.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-4Ltv79Acof9lRtjt7iUkmBNQfTaYO2/r2b441PVkOX94pHsTh6hMnznJIxUz/Idktoc4U+bC7F+WNvanLYdU2g==","shasum":"a65f34e1ed0485a5db81c12dbd0baa7ad239046c","tarball":"https://registry.npmjs.org/@audc/retry-axios/-/retry-axios-3.2.6.tgz","fileCount":6,"unpackedSize":37004,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDdUvvawCWYaM73TZBQ46cZkiKL6iFMyXD4PCMvzzsRjQIhAO3k6IOh/qvIcuHbo7Ta5Js404MfxC8bv2rZT/d53wle"}]},"_npmUser":{"name":"orgads","email":"orgads@gmail.com"},"directories":{},"maintainers":[{"name":"orgads","email":"orgads@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/retry-axios_3.2.6_1749405259853_0.7565242328258088"},"_hasShrinkwrap":false}},"time":{"created":"2024-06-13T14:42:16.143Z","modified":"2025-06-08T17:54:20.227Z","3.2.0":"2024-06-13T14:42:16.418Z","3.2.1":"2024-06-13T15:09:54.070Z","3.2.2":"2024-06-13T15:33:56.326Z","3.2.3":"2024-06-13T15:40:54.635Z","3.2.4":"2024-10-13T20:14:35.756Z","3.2.5":"2024-10-13T20:31:54.349Z","3.2.6":"2025-06-08T17:54:20.051Z"},"bugs":{"url":"https://github.com/audiocodes/retry-axios/issues"},"author":{"name":"Justin Beckwith"},"license":"Apache-2.0","homepage":"https://github.com/audiocodes/retry-axios#readme","keywords":["axios","retry"],"repository":{"type":"git","url":"git+https://github.com/audiocodes/retry-axios.git"},"description":"Retry HTTP requests with Axios.","maintainers":[{"name":"orgads","email":"orgads@gmail.com"}],"readme":"# retry-axios\n\n> Use Axios interceptors to automatically retry failed requests.  Super flexible. Built in exponential backoff.\n\n[![NPM Version][npm-image]][npm-url]\n[![GitHub Actions][github-image]][github-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![codecov][codecov-image]][codecov-url]\n[![style badge][gts-image]][gts-url]\n\n## Installation\n\n```sh\nnpm install retry-axios\n```\n\n## Usage\n\nTo use this library, import it alongside of `axios`:\n\n```js\n// Just import rax and your favorite version of axios\nconst rax = require('retry-axios');\nconst axios = require('axios');\n```\n\nOr, if you're using TypeScript / es modules:\n\n```js\nimport * as rax from 'retry-axios';\nimport axios from 'axios';\n```\n\nYou can attach to the global `axios` object, and retry 3 times by default:\n\n```js\nconst interceptorId = rax.attach();\nconst res = await axios('https://test.local');\n```\n\nOr you can create your own axios instance to make scoped requests:\n\n```js\nconst myAxiosInstance = axios.create();\nmyAxiosInstance.defaults.raxConfig = {\n  instance: myAxiosInstance\n};\nconst interceptorId = rax.attach(myAxiosInstance);\nconst res = await myAxiosInstance.get('https://test.local');\n```\n\nYou have a lot of options...\n\n```js\nconst interceptorId = rax.attach();\nconst res = await axios({\n  url: 'https://test.local',\n  raxConfig: {\n    // Retry 3 times on requests that return a response (500, etc) before giving up.  Defaults to 3.\n    retry: 3,\n\n    // Retry twice on errors that don't return a response (ENOTFOUND, ETIMEDOUT, etc).\n    // 'noResponseRetries' is limited by the 'retry' value.\n    noResponseRetries: 2,\n\n    // Milliseconds to delay at first.  Defaults to 100. Only considered when backoffType is 'static'\n    retryDelay: 100,\n\n    // HTTP methods to automatically retry.  Defaults to:\n    // ['GET', 'HEAD', 'OPTIONS', 'DELETE', 'PUT']\n    httpMethodsToRetry: ['GET', 'HEAD', 'OPTIONS', 'DELETE', 'PUT'],\n\n    // The response status codes to retry.  Supports a double\n    // array with a list of ranges.  Defaults to:\n    // [[100, 199], [429, 429], [500, 599]]\n    statusCodesToRetry: [[100, 199], [429, 429], [500, 599]],\n\n    // If you are using a non static instance of Axios you need\n    // to pass that instance here (const ax = axios.create())\n    instance: ax,\n\n    // You can set the backoff type.\n    // options are 'exponential' (default), 'static' or 'linear'\n    backoffType: 'exponential',\n\n    // You can detect when a retry is happening, and figure out how many\n    // retry attempts have been made\n    onRetryAttempt: err => {\n      const cfg = rax.getConfig(err);\n      console.log(`Retry attempt #${cfg.currentRetryAttempt}`);\n    }\n  }\n});\n```\n\nIf the logic in onRetryAttempt requires to be asynchronous, you can return a promise, then retry will be executed only after the promise is resolved:\n\n```js\nconst res = await axios({\n  url: 'https://test.local',\n  raxConfig: {\n    onRetryAttempt: err => {\n      return new Promise((resolve, reject) => {\n        // call a custom asynchronous function\n        refreshToken(err, function(token, error) {\n          if (!error) {\n            window.localStorage.setItem('token', token);\n            resolve();\n          } else {\n            reject();\n          }\n        });\n      });\n    }\n  }\n});\n```\n\nOr if you want, you can just decide if it should retry or not:\n\n```js\nconst res = await axios({\n  url: 'https://test.local',\n  raxConfig: {\n    // Override the decision making process on if you should retry\n    shouldRetry: err => {\n      const cfg = rax.getConfig(err);\n      return true;\n    }\n  }\n});\n```\n\nIf you want to add custom retry logic without duplicating too much of the built-in logic, `rax.shouldRetryRequest` will tell you if a request would normally be retried:\n```js\nconst res = await axios({\n  url: 'https://test.local',\n  raxConfig: {\n    // Override the decision making process on if you should retry\n    shouldRetry: err => {\n      const cfg = rax.getConfig(err);\n      if (cfg.currentRetryAttempt >= cfg.retry) return false // ensure max retries is always respected\n\n      // Always retry this status text, regardless of code or request type\n      if (err.response.statusText.includes('Try again')) return true\n\n      // Handle the request based on your other config options, e.g. `statusCodesToRetry`\n      return rax.shouldRetryRequest(err)\n    }\n  }\n});\n```\n\n## How it works\n\nThis library attaches an `interceptor` to an axios instance you pass to the API. This way you get to choose which version of `axios` you want to run, and you can compose many interceptors on the same request pipeline.\n\n## License\n\n[Apache-2.0](LICENSE)\n\n[github-image]: https://github.com/JustinBeckwith/retry-axios/workflows/ci/badge.svg\n[github-url]: https://github.com/JustinBeckwith/retry-axios/actions/\n[codecov-image]: https://codecov.io/gh/JustinBeckwith/retry-axios/branch/main/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/JustinBeckwith/retry-axios\n[gts-image]: https://img.shields.io/badge/code%20style-Google%20%E2%98%82%EF%B8%8F-blue.svg\n[gts-url]: https://www.npmjs.com/package/gts\n[npm-image]: https://img.shields.io/npm/v/retry-axios.svg\n[npm-url]: https://npmjs.org/package/retry-axios\n[snyk-image]: https://snyk.io/test/github/JustinBeckwith/retry-axios/badge.svg\n[snyk-url]: https://snyk.io/test/github/JustinBeckwith/retry-axios\n","readmeFilename":"README.md"}