axios-retry-enhancer
TypeScript icon, indicating that this package has built-in type declarations

0.0.8 • Public • Published

axios-retry-enhancer

test

npm

npm

Retry your http request easily when you need

Installation

npm install axios-retry-enhancer

Usage

import axiosRetryEnhancer from 'axios-retry-enhancer'
import axios from 'axios'

const client = axios.create()
axiosRetryEnhancer(client, {
  // same options with axios-retry. See https://github.com/softonic/axios-retry#options
})

interface Result<T = unknown> {
  code: number
  data: T
}

client.get<Result>('http://example.com/test', {
  retry: {
    // The request will retry when the code isn't 0 even the http code is 200
    shouldRetry: (res: Result) => res.code !== 0,
  },
})

The difference with axios-retry

axios-retry only can retry the request when the request fail. But sometimes there are some conditions that we decide to retry even the request success. axios-retry-enhancer wrap the axios-retry so that it support all the feature provided by axios-retry

Testing

npm run test

Relation

axios-retry

/axios-retry-enhancer/

    Package Sidebar

    Install

    npm i axios-retry-enhancer

    Weekly Downloads

    4

    Version

    0.0.8

    License

    MIT

    Unpacked Size

    10.1 kB

    Total Files

    15

    Last publish

    Collaborators

    • flytam