node-fetch-retry
Advanced tools
Comparing version 1.1.2 to 2.0.0
@@ -1,3 +0,1 @@ | ||
const fetch = require('node-fetch'); | ||
module.exports = async (url, opts) => { | ||
@@ -8,9 +6,9 @@ let retry = opts && opts.retry || 3 | ||
try { | ||
return await fetch(url, opts) | ||
return await import('node-fetch').then(({ default: fetch }) => fetch(url, opts)) | ||
} catch(e) { | ||
if (opts && opts.callback) { | ||
opts.callback(retry) | ||
} | ||
} | ||
retry = retry - 1 | ||
if (retry == 0) { | ||
if (retry === 0) { | ||
throw e | ||
@@ -17,0 +15,0 @@ } |
{ | ||
"name": "node-fetch-retry", | ||
"version": "1.1.2", | ||
"version": "2.0.0", | ||
"description": "Retry library for node-fetch", | ||
@@ -27,7 +27,8 @@ "scripts": { | ||
"mocha": "^9.0.3", | ||
"should": "^13.2.3" | ||
"should": "^13.2.3", | ||
"timeout-signal": "^1.1.0" | ||
}, | ||
"dependencies": { | ||
"node-fetch": "^2.6.1" | ||
"node-fetch": "^3.0.0" | ||
} | ||
} |
require('should'); | ||
const assert = require('assert'); | ||
const timeoutSignal = require('timeout-signal'); | ||
const fetch = require('..'); | ||
@@ -11,3 +12,3 @@ | ||
retry: 3, | ||
timeout: 2 | ||
signal: timeoutSignal(2), | ||
} | ||
@@ -28,3 +29,3 @@ try { | ||
retry: 3, | ||
timeout: 2, | ||
signal: timeoutSignal(2), | ||
callback: retry => { | ||
@@ -31,0 +32,0 @@ calls.push(retry) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7937
3
130
+ Addeddata-uri-to-buffer@4.0.1(transitive)
+ Addedfetch-blob@3.2.0(transitive)
+ Addedformdata-polyfill@4.0.10(transitive)
+ Addednode-domexception@1.0.0(transitive)
+ Addednode-fetch@3.3.2(transitive)
+ Addedweb-streams-polyfill@3.3.3(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removedtr46@0.0.3(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)
Updatednode-fetch@^3.0.0