• Version 3.1.3
  • Published
  • 36.4 kB
  • No dependencies
  • Apache-2.0 license


npm i retry-axios
yarn add retry-axios
pnpm add retry-axios


Retry HTTP requests with Axios.



function attach

attach: (instance?: AxiosInstance) => number;
  • Attach the interceptor to the Axios instance.

    Parameter instance

    The optional Axios instance on which to attach the interceptor.


    The id of the interceptor attached to the axios instance.

function detach

detach: (interceptorId: number, instance?: AxiosInstance) => void;
  • Eject the Axios interceptor that is providing retry capabilities.

    Parameter interceptorId

    The interceptorId provided in the config.

    Parameter instance

    The axios instance using this interceptor.

function getConfig

getConfig: (error: AxiosError) => RetryConfig | undefined;
  • Acquire the raxConfig object from an AxiosError if available.

    Parameter err

    The Axios error with a config object.

function shouldRetryRequest

shouldRetryRequest: (error: AxiosError) => boolean;
  • Determine based on config if we should retry the request.

    Parameter err

    The AxiosError passed to the interceptor.


interface RetryConfig

interface RetryConfig {}
  • Configuration for the Axios request method.

property backoffType

backoffType?: 'linear' | 'static' | 'exponential';
  • Backoff Type; 'linear', 'static' or 'exponential'.

property checkRetryAfter

checkRetryAfter?: boolean;
  • Whether to check for 'Retry-After' header in response and use value as delay. Defaults to true.

property currentRetryAttempt

currentRetryAttempt?: number;
  • The number of retries already attempted.

property httpMethodsToRetry

httpMethodsToRetry?: string[];
  • The HTTP Methods that will be automatically retried. Defaults to ['GET','PUT','HEAD','OPTIONS','DELETE']

property instance

instance?: AxiosInstance;
  • The instance of the axios object to which the interceptor is attached.

property maxRetryAfter

maxRetryAfter?: number;
  • Max permitted Retry-After value (in ms) - rejects if greater. Defaults to 5 mins.

property maxRetryDelay

maxRetryDelay?: number;
  • Ceiling for calculated delay (in ms) - delay will not exceed this value.

property noResponseRetries

noResponseRetries?: number;
  • When there is no response, the number of retries to attempt. Defaults to 2.

property onRetryAttempt

onRetryAttempt?: (error: AxiosError) => void;
  • Function to invoke when a retry attempt is made.

property retry

retry?: number;
  • The number of times to retry the request. Defaults to 3.

property retryDelay

retryDelay?: number;
  • The amount of time to initially delay the retry. Defaults to 100.

property shouldRetry

shouldRetry?: (error: AxiosError) => boolean;
  • Function to invoke which determines if you should retry

property statusCodesToRetry

statusCodesToRetry?: number[][];
  • The HTTP response status codes that will automatically be retried. Defaults to: [[100, 199], [429, 429], [500, 599]]

Type Aliases

type RaxConfig

type RaxConfig = {
raxConfig: RetryConfig;
} & AxiosRequestConfig;

    Package Files (1)

    Dependencies (0)

    No dependencies.

    Dev Dependencies (12)

    Peer Dependencies (1)


    To add a badge like this badgeto your package's README, use the codes available below.

    You may also use to create a custom badge linking to

    • Markdown
    • HTML
      <a href=""><img src="" alt=""></a>