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 1.0.2 to 2.0.0-ngei-508.1

11

package.json
{
"name": "@nuskin/axios-util",
"version": "1.0.2",
"version": "2.0.0-ngei-508.1",
"description": "An Axios utility ...",

@@ -22,2 +22,3 @@ "main": "src/index.js",

"devDependencies": {
"axios": "0.27.2",
"axios-mock-adapter": "1.19.0",

@@ -30,9 +31,11 @@ "eslint": "7.19.0",

"jest-sonar-reporter": "2.0.0",
"json-colorizer": "2.2.2",
"prettier": "2.2.1"
},
"dependencies": {
"axios": "0.21.1",
"axios-retry": "3.1.9"
"axios-retry": "3.1.9",
"deepmerge": "4.2.2"
},
"peerDependencies": {
"axios": "^0.27.2"
},
"files": [

@@ -39,0 +42,0 @@ "/src"

# @nuskin/axios-util
`axios-util` allows you to use Axios in the exact same way you would use Axios
by itself, with one exception. `axios-util` builds the `retry` and `timeout`
resiliency patterns into Axios for you.
by itself. By default `axios-util` will set the **timeout** to _10000ms_.
The default timeout has been set 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 has been implemented with the [axios-retry](https://www.npmjs.com/package/axios-retry) module. All defaults of `axios-retry` are used except for *retryDelay*. *retryDelay*
is set to *axiosRetry.exponentialDelay*
## Installing

@@ -17,3 +16,3 @@

```bash
npm add @nuskin/axios-util
npm install @nuskin/axios-util
```

@@ -39,8 +38,12 @@

```js
const { axios, axiosRetry } = require('@nuskin/axios-util')
const { axios, getRetryAxiosInstance } = require('@nuskin/axios-util')
// Custom retry delay
axiosRetry(axios, { retryDelay: (retryCount) => {
return retryCount * 1000;
}})
const myAxiosWithRetry = getRetryAxiosInstance({
retries: 3,
shouldResetTimeout: true,
retryDelay: (retryCount) => {
return retryCount * 1000;
}
})
```

@@ -47,0 +50,0 @@

@@ -7,3 +7,4 @@ 'use strict'

*/
const axios = require('axios')
const merge = require('deepmerge')
const axios = require('axios').default
const axiosRetry = require('axios-retry')

@@ -13,7 +14,17 @@

axiosRetry(axios, { retryDelay: axiosRetry.exponentialDelay })
/**
*
* @param {Object} options `axios-retry` options to pass in.
* @returns {AxiosInstance}
*/
const getRetryAxiosInstance = (options = {}) => {
const retryConfig = merge({ retryDelay: axiosRetry.exponentialDelay }, options)
const axiosRetryInstance = axios.create()
axiosRetry(axiosRetryInstance, retryConfig)
return axiosRetryInstance
}
module.exports = {
axios,
axiosRetry
getRetryAxiosInstance
}
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