Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

axios-retry-interceptor

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axios-retry-interceptor

Axios Interceptor to retry failed http calls

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Axios Retry Interceptor

Build Status dependencies Status npm version License: MIT

Configurable Axios Interceptor to retry failed http calls.

Install

npm install --save axios-retry-interceptor

Usage

Import

import retryInterceptor from 'axios-retry-interceptor';
// or
const retryInterceptor = require('axios-retry-interceptor');

Set the interceptor for your axios instance. Voila! ✨

retryInterceptor(axios, {
  maxAttempts: 3,
  waitTime: 1000
});

API

retryInterceptor(axiosInstance, options)

  • axiosInstance - your axios instance
  • options - config for retry interceptor

Options

maxAttempts

Max number of times the interceptor should retry the failed http call.

Type: Number

Default: 3

Example: maxAttempts: 5

waitTime

Duration between each retry attempt in milliseconds(1s=1000ms).

Type: Number

Default: 0

Example: waitTime: 3000

errorCodes

Response errorCodes for which the interceptor should retry.

Ideally any implementation should retry only 5xx status(server errors) and should not retry 4xx status(client errors). The reason is, if a http call fails with a client error, then the retry call will have the same headers/params and will obviously fail. So by default all 5xx errors will be retried. If you want to customize the status for which the retries should be made, use this config.

Type: Array

Default: []

Example: errorCodes: [500, 501, 401]

Author's note

Ideally only idempotent http methods (GET, PUT, DELETE, HEAD, OPTIONS) should be retried on failed http calls. Non-idempotent methods like POST should NOT be retried and that's why this library will not permit retry of non-idempotent methods.

License

MIT © Dinesh Pandiyan

Keywords

FAQs

Package last updated on 26 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc