Installations
npm install @ambassify/fetch-retried
Developer Guide
Typescript
No
Module System
CommonJS, UMD
Node Version
18.14.0
NPM Version
9.3.1
Score
65.6
Supply Chain
92.5
Quality
79.6
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
ambassify
Download Statistics
Total Downloads
36,853
Last Day
3
Last Week
19
Last Month
174
Last Year
2,270
GitHub Statistics
3 Stars
25 Commits
2 Watching
1 Branches
3 Contributors
Bundle Size
2.37 kB
Minified
1.08 kB
Minified + Gzipped
Package Meta Information
Latest Version
2.0.4
Package Id
@ambassify/fetch-retried@2.0.4
Unpacked Size
17.91 kB
Size
4.19 kB
File Count
11
NPM Version
9.3.1
Node Version
18.14.0
Publised On
03 Feb 2023
Total Downloads
Cumulative downloads
Total Downloads
36,853
Last day
-87.5%
3
Compared to previous day
Last week
-79.8%
19
Compared to previous week
Last month
-13.4%
174
Compared to previous month
Last year
-59%
2,270
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Dev Dependencies
7
fetch-retried
Use the fetch API to run requests, implementing retries
Installation
1npm install --save @ambassify/fetch-retried
Usage
You can use the fetch api as per usual. The only thing different is the source of your fetch method. Here you use fetchRetried to create a fetch method that will use your desired config.
1const fetchRetried = require('@ambassify/fetch-retried'); 2const fetch = fetchRetried({ delay: 100 }); 3 4fetch('https://www.google.com') 5 .then(resp => resp.json()) 6 .then(json => console.log(json));
Options
All options are optional and have default values.
- delay: When using the default
exponential
backoff, the delay used to calculate the timeout. Otherwise a method that calculated the timeout used. (default:200
) - retries: The number of times to retry a request. (default:
5
) - isOK: A method that determines whether a request succeeded by returning
true
orfalse
when passed a response. (default:(resp) => resp.ok
) - shouldRetryError: When fetch throws an error this method determines whether the request is retried by returning
true
orfalse
(default:() => true
) - retryMethods: Which HTTP verbs to retry (default:
['PUT', 'DELETE', 'GET', 'HEAD', 'PATCH', 'OPTIONS']
) - fetch: The underlying fetch implementation to use. (default:
require('node-fetch')
)
Backoff strategies
Strategies are attached to the default import of this package and can be accessed using.
1const fetchRetried = require('@ambassify/fetch-retried'); 2 3fetchRetried.exponential; 4// OR 5fetchRetried.binaryExponential; 6 7// Usage: 8const fetch = fetchRetried({ 9 delay: fetchRetried.exponential(10) 10}) 11// OR 12const fetch = fetchRetried({ 13 delay: fetchRetried.binaryExponential() 14})
exponential
1function exponential(delay) { 2 return (attempts) => (attempts * attempts) * delay; 3}
binaryExponential
1function binaryExponential(delay = 1) { 2 return (attempts) => (Math.pow(2, attempts) - 1) * delay; 3}
Contribute
We really appreciate any contribution you would like to make, so don't hesitate to report issues or submit pull requests.
License
This project is released under a MIT license.
About us
If you would like to know more about us, be sure to have a look at our website, or our Twitter accounts Ambassify, Sitebase, JorgenEvens
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
branch protection is not maximal on development and all release branches
Details
- Info: 'allow deletion' disabled on branch 'master'
- Info: 'force pushes' disabled on branch 'master'
- Warn: 'branch protection settings apply to administrators' is disabled on branch 'master'
- Warn: 'stale review dismissal' is disabled on branch 'master'
- Warn: required approving review count is 1 on branch 'master'
- Warn: codeowners review is not required on branch 'master'
- Warn: 'last push approval' is disabled on branch 'master'
- Warn: no status checks found to merge onto branch 'master'
- Info: PRs are required in order to make changes on branch 'master'
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/21 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 8 are checked with a SAST tool
Score
3.3
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More