Exciting release!Introducing "safe npm". Learn more
Socket
Log inDemoInstall

axios-retry-after

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Issues
File Explorer

Advanced tools

axios-retry-after

A tiny HTTP 429 Retry-After interceptor for axios

    2.0.0latest
    GitHub

Version published
Maintainers
1
Weekly downloads
3,352
increased by85.6%

Weekly downloads

Changelog

Source

2.0.0 (2022-10-05)

⚠ BREAKING CHANGES

  • upgrade to axios v1.0.0
  • package: drop support for Node.js < 14
  • module: now an ES6 module

Features

  • module: now an ES6 module (7ce1787)

  • upgrade to axios v1.0.0 (56b8bfa)

  • package: drop support for Node.js < 14 (b0f2efe)

Changelog

Readme

Source

axios-retry-after

Build Status Download Status Sponsor on GitHub

A tiny HTTP retry interceptor for axios.

This interceptor catches HTTP 429 errors, reads the Retry-After header, and retries the request at the proper type.

Installation

With NPM:

npm install --save axios-retry-after

With Yarn:

yarn add axios-retry-after

Example usage

import axios from 'axios' import retry from 'axios-retry-after' const client = axios.createClient() client.interceptors.response.use(null, retry(client))

Customizing retry behavior

You can optionally customize the behavior of this interceptor by passing a second argument including one or more of the methods demonstrated below:

client.interceptors.response.use(null, retry(client, { // Determine when we should attempt to retry isRetryable (error) { return ( error.response && error.response.status === 429 && // Use X-Retry-After rather than Retry-After, and cap retry delay at 60 seconds error.response.headers['x-retry-after'] && error.response.headers['x-retry-after'] <= 60 ) } // Customize the wait behavior wait (error) { return new Promise( // Use X-Retry-After rather than Retry-After resolve => setTimeout(resolve, error.response.headers['x-retry-after']) ) } // Customize the retry request itself retry (axios, error) { if (!error.config) { throw error } // Apply request customizations before retrying // ... return axios(error.config) } }))

Keywords

FAQs

Last updated on 05 Oct 2022

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket
support@socket.devSocket SOC 2 Logo

Product

  • Package Issues
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc