@nuskin/axios-util
axios-util
allows you to use Axios in the exact same way you would use Axios
by itself. By default axios-util
will set the timeout to 10000ms.
Retry has been implemented with the axios-retry module.
Use getRetryAxiosInstance()
to get an axios instance with retry
added to it. All defaults of
axios-retry
are used except for retryDelay. retryDelay is set to axiosRetry.exponentialDelay.
You can set your own behavior by providing an axios-retry
options object to getRetryAxiosInstance()
.
Installing
Usng npm:
npm install @nuskin/axios-util
Usng yarn:
yarn add @nuskin/axios-util
Example usage
const { axios } = require('@nuskin/axios-util')
Customizing retry
You can customize your retry logic by accessing axios-retry
.
const { axios, getRetryAxiosInstance } = require('@nuskin/axios-util')
const myAxiosWithRetry = getRetryAxiosInstance({
retries: 3,
shouldResetTimeout: true,
retryDelay: (retryCount) => {
return retryCount * 1000;
}
})
Other possibilities for axios-util
Resources
License
MIT