retry-axios

  • Version 2.6.0
  • Published
  • 71.8 kB
  • No dependencies
  • Apache-2.0 license

Install

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

Overview

Retry HTTP requests with Axios.

Index

Functions

function attach

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

    Parameter instance

    The optional Axios instance on which to attach the interceptor.

    Returns

    The id of the interceptor attached to the axios instance.

function detach

detach: (interceptorId: number, instance?: any) => 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: (err: any) => RetryConfig | undefined;
  • Acquire the raxConfig object from an AxiosError if available.

    Parameter err

    The Axios error with a config object.

function shouldRetryRequest

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

    Parameter err

    The AxiosError passed to the interceptor.

Interfaces

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?: (err: 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?: (err: 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 (16)

    Peer Dependencies (1)

    Badge

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

    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/retry-axios.

    • Markdown
      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/retry-axios)
    • HTML
      <a href="https://www.jsdocs.io/package/retry-axios"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>