Registry / devops / axios-retry-after

axios-retry-after

JSON →
library2.1.0jsnpmunverified

A tiny HTTP 429 Retry-After interceptor for axios, version 2.1.0. This package intercepts HTTP 429 Too Many Requests errors, reads the Retry-After header, and automatically retries the request after the specified delay. It is designed to be lightweight and integrates as an axios response interceptor. The package is actively maintained and supports customization of retry conditions, wait logic, and retry request handling. Unlike broader retry libraries, it focuses specifically on Retry-After behavior. It requires axios ^1.0.0 as a peer dependency and Node.js >= 14.

npm install axios-retry-after
INSTALL
IMPORT
SIG · AXIOS-RETRY-AFTER
A
axios-retry-after
devopsjavascriptv2.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import retry from 'axios-retry-after'
const { retry } = require('axios-retry-after')
The package exports a single default function. CommonJS require returns the default directly: const retry = require('axios-retry-after').
type RetryOptions
import type { RetryOptions } from 'axios-retry-after'
import { RetryOptions } from 'axios-retry-after'
RetryOptions is a TypeScript type export, not a value. Use import type or import { type RetryOptions }.

Shows basic setup: import axios and retry, create an axios client, attach retry interceptor, and make a GET request that will automatically retry on 429.

import axios from 'axios'; import retry from 'axios-retry-after'; const client = axios.create(); client.interceptors.response.use(null, retry(client)); // Example request client.get('https://api.example.com/data') .then(response => console.log(response.data)) .catch(error => console.error(error));
Debug
Known issues
gotcharetry function must be called with the axios client instance as the first argument, not the request config.
fix
Use retry(client) when adding to interceptors, not retry() or retry(config).
affects: >=1.0.0
deprecatedDefault export is the retry function. There is no named export 'retry'.
fix
Use import retry from 'axios-retry-after' or const retry = require('axios-retry-after').
affects: >=2.0.0
gotchaThe interceptor must be attached to the response interceptors as the error handler (second argument to .use).
fix
Do: client.interceptors.response.use(null, retry(client)).
affects: >=1.0.0
breakingVersion 2.0.0 dropped support for Node < 14 and changed the export to ESM-only (no default CommonJS export).
fix
Update to Node >= 14 and use import syntax or dynamic require() as require('axios-retry-after').default.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: retry is not a function
Importing the package incorrectly, e.g., using named import instead of default import.
fix
Use import retry from 'axios-retry-after' or const retry = require('axios-retry-after') (CommonJS).
Error: Cannot find module 'axios-retry-after'
Package not installed or missing from node_modules.
fix
Run npm install axios-retry-after --save.
Uncaught (in promise) Error: retry is not a function
Calling retry() without passing the axios client as first argument.
fix
Ensure retry(client) is passed to the interceptor, e.g., client.interceptors.response.use(null, retry(client)).
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies
axiosrequiredPeer dependency; axios must be installed and used to create the client that the interceptor attaches to.
Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
1
Resources
axios-retry-after — npm install axios-retry-after · libregistry