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

@nuskin/axios-util

Package Overview
Dependencies
Maintainers
5
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nuskin/axios-util - npm Package Compare versions

Comparing version 2.3.0-esm-cjs.1 to 2.3.0

2

package.json
{
"name": "@nuskin/axios-util",
"version": "2.3.0-esm-cjs.1",
"version": "2.3.0",
"description": "An Axios utility ...",

@@ -5,0 +5,0 @@ "main": "src/index.js",

# @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_.
`axios-util` enables you to utilize Axios as you normally would. By default, `axios-util` sets
the **timeout** to _10000ms_.
Retry has been implemented with the [axios-retry](https://www.npmjs.com/package/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()`.
Retry functionality is implemented using the [axios-retry](https://www.npmjs.com/package/axios-retry) module. Utilize `getRetryAxiosInstance()` to obtain an Axios instance with retry capabilities. All default settings of `axios-retry` are applied, except for the *retryDelay*, which is set to *axiosRetry.exponentialDelay*. You can customize the retry behavior by supplying an `axios-retry` options object to `getRetryAxiosInstance()`.
## Installing
Usng npm:
Using npm:

@@ -19,3 +16,3 @@ ```bash

Usng yarn:
Using yarn:

@@ -28,14 +25,17 @@ ```bash

For ESM syntax, use `import`:
```js
const { axios } = require('@nuskin/axios-util')
import { axios, getRetryAxiosInstance } from '@nuskin/axios-util'
```
// Now use axios as you normally would
For CommonJS, use `require`:
```js
const { axios, getRetryAxiosInstance } = require('@nuskin/axios-util')
```
## Customizing retry
## Customizing Retry
You can customize your retry logic by accessing `axios-retry`.
To customize the retry logic, access `axios-retry` with ESM import syntax:
```js
const { getRetryAxiosInstance } = require('@nuskin/axios-util')
let retryDelay = process.env.AXIOS_RETRY_DELAY || 5000

@@ -49,7 +49,7 @@ const myAxiosWithRetry = getRetryAxiosInstance({

retryCondition: (error) => {
// if retry condition is not specified, by default idempotent requests are retried
// If retry condition is not specified, by default, idempotent requests are retried
return error.response?.status >= 500 || error.code === 'ECONNABORTED'
},
onRetry: (retryCount, error, requestConfig) => {
log.info(
console.log(
{

@@ -64,3 +64,3 @@ retryCount,

)
return true
return true;
}

@@ -70,13 +70,9 @@ })

## Other possibilities for axios-util
- analytics
- caching [axios-cache-adapter](https://www.npmjs.com/package/axios-cache-adapter)
- logging [axios-logger](https://www.npmjs.com/package/axios-logger)
## Other Possibilities for axios-util
- Analytics
- Caching with [axios-cache-adapter](https://www.npmjs.com/package/axios-cache-adapter)
- Logging with [axios-logger](https://www.npmjs.com/package/axios-logger)
## Resources
- Changelog could go here
## License
[MIT](https://opensource.org/licenses/MIT)
[MIT](https://opensource.org/licenses/MIT)
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