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

axios-retry

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axios-retry - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

LICENSE

7

es/index.js

@@ -30,3 +30,6 @@ import isRetryAllowed from 'is-retry-allowed';

*/
export default function axiosRetry(axios, { retries = 3 } = {}) {
export default function axiosRetry(axios, {
retries = 3,
retryCondition = error => !error.response
} = {}) {
axios.interceptors.response.use(null, error => {

@@ -42,3 +45,3 @@ const config = error.config;

const shouldRetry = !error.response
const shouldRetry = retryCondition(error)
&& error.code !== 'ECONNABORTED'

@@ -45,0 +48,0 @@ && config.retryCount < retries

@@ -46,2 +46,6 @@ 'use strict';

var retries = _ref$retries === undefined ? 3 : _ref$retries;
var _ref$retryCondition = _ref.retryCondition;
var retryCondition = _ref$retryCondition === undefined ? function (error) {
return !error.response;
} : _ref$retryCondition;

@@ -58,3 +62,3 @@ axios.interceptors.response.use(null, function (error) {

var shouldRetry = !error.response && error.code !== 'ECONNABORTED' && config.retryCount < retries && (0, _isRetryAllowed2.default)(error);
var shouldRetry = retryCondition(error) && error.code !== 'ECONNABORTED' && config.retryCount < retries && (0, _isRetryAllowed2.default)(error);

@@ -61,0 +65,0 @@ if (shouldRetry) {

{
"name": "axios-retry",
"version": "1.1.1",
"version": "1.2.0",
"author": "Rubén Norte <ruben.norte@softonic.com>",

@@ -5,0 +5,0 @@ "description": "Axios plugin that intercepts failed requests and retries them whenever posible.",

@@ -37,2 +37,9 @@ # axios-retry

## Options
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| retries | `Number` | 3 | The number of times to retry before failing |
| retryCondition | `Function` | `error => !error.response` | A callback to further control if a request should be retried. By default, it retries if the result did not have a response. |
## Testing

@@ -39,0 +46,0 @@

Sorry, the diff of this file is not supported yet

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