Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
The ultra-lightweight Node.js HTTP client.
This is a wrapper around Phin that adds support for retry & looks like request-promise.
npm install phin-retry
const request = require('phin-retry');
// should be used in async context
const response = await request.get('https://jsonplaceholder.typicode.com/posts/1');
await request.post({
url: 'http://localhost:9393/api/post',
body: { msg: 'input' },
retry: 3,
delay: 500
});
// custom retry, error & delay strategy
const response = await request.delete({
url: 'http://localhost:9393/api/delete',
auth: {
user: 'name',
pass: 'secret'
},
errorStrategy: ({response, error, options}) => {
if (error) return true;
if (response.statusCode >= 400) {
return false;
}
return true;
},
retryStrategy: ({response, error, options}) => {
if (error) return true;
if (options.method === 'POST') return false;
if (response.statusCode >=200 && response.StatusCode < 300) {
return false;
}
return true;
},
delayStrategy: ({response, error, options, delay}) => {
if (error) return 5000;
return 2000;
},
});
request.phin
.Access default options through request.defaults
.
Option | Type | Description |
---|---|---|
retry | number | max no of times to retry (1) |
delay | number | delay between retries (100ms) |
networkErrorDelay | number | delay for network errors (1000ms) |
retryStrategy | function | default retry strategy function |
delayStrategy | function | default delay strategy function |
errorStrategy | function | default error strategy function |
It supports all options from phin, refer Phin for more details.
Method | Type | Description |
---|---|---|
url | string | request url |
qs | object | query parameters |
auth | object | authentication object |
headers | object | headers object |
retry | number | max no of times to retry |
delay | number | delay between retries |
body | any | equivalent to data in phin |
fullResponse | boolean | returns full phin response |
retryStrategy | function | custom retry strategy function |
delayStrategy | function | custom delay strategy function |
errorStrategy | function | custom error strategy function |
FAQs
The ultra-lightweight Node.js HTTP client
The npm package phin-retry receives a total of 10,556 weekly downloads. As such, phin-retry popularity was classified as popular.
We found that phin-retry demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.