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

robust-http-fetch

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

robust-http-fetch - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

4

package.json
{
"name": "robust-http-fetch",
"description": "Redo the http request when timeout or failed, aim at providing resilience over plain one-off fetch request by doing retry delayed/failed requests",
"version": "1.0.8",
"version": "1.0.9",
"repository": {

@@ -52,4 +52,4 @@ "type": "git",

"publishConfig": {
"registry":"http://registry.npmjs.org/"
"registry": "http://registry.npmjs.org/"
}
}

@@ -20,9 +20,9 @@ <h1 align="center">Robust Http Fetch</h1>

This robust-http-fetch is a light-weight and [100%-test-coverage](https://codecov.io/gh/gaoqing/robust-http-fetch) javascript utils helping to make robust http fetch request.
This `robust-http-fetch` is a light-weight and [100%-test-coverage](https://codecov.io/gh/gaoqing/robust-http-fetch) javascript utils helping to make robust http fetch request.
The underlying fetch will be delegated either to [window.fetch](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch) when use in browser or [node-fetch](https://www.npmjs.com/package/node-fetch) when use in node server.
It makes request to the provided url, if response is not received in timely manner('init.timeout' config below) or failed (fragile network etc), it will fire another request to race(up to 'init.maxRequests' requests to fire if none of them are well resolved).
It makes request to the provided url, if response is not received in timely manner(`init.timeout` config below) or failed (fragile network etc), it will fire another request to race(up to `init.maxRequests` requests to fire if none of them are well resolved).
Request waits upto 'init.timeout' milliseconds for response before sending a retry, if more than one request are still in-flight, then they are racing, the earliest good response will be resolved with and returned. Details refer to usage section in this page.
Request waits upto `init.timeout` milliseconds for response before sending a retry, if more than one request are still in-flight, then they are racing, the earliest good response will be resolved with and returned. Details refer to usage section in this page.

@@ -32,2 +32,3 @@ ***Caveats***: only use this utils when your request is [idempotent](https://developer.mozilla.org/en-US/docs/Glossary/Idempotent), for example GET, no matter how many times calling GET, should have same result and data integrity still maintained,

see also in a github page: https://gaoqing.github.io/robust-http-fetch/
## Installation

@@ -52,9 +53,9 @@

/**
* below example use the Promise resolve callback function as the callback to the 3rd parameter,
* below input arguments for demonstration only. It use the Promise resolve callback function as the callback to the 3rd parameter,
* but you can use your custom callback function which accept a Promise object as its argument.
* @input url, required, the resource destination
* @input timeout, required, here request will wait 3000ms before firing retry request
* @input maxRequests, required, here upto 3 requests to fire in case previous requests delayed or not well resolved
* @input method/body/headers...and more, on demand properties, usage refer to window.fetch(init config)/node-fetch(options config)
* @input resolve, required, callback function to be invoked with a Promise object later
* @input {timeout}, required, here request will wait 3000ms before firing retry request
* @input {maxRequests}, required, here upto 3 requests to fire in case previous requests delayed or not well resolved
* @input {method/body/headers}...and more, on demand properties, usage refer to `window.fetch`(init config)/`node-fetch`(options config)
* @input resolve, required, any callback function to be invoked with a Promise object later
* @input console.log, optional function, any function accept a string argument

@@ -91,3 +92,3 @@ **/

| url | true |string | The resource destination url to make this request to
| init | true |object | It can have properties in ['init'](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters) parameter of window.fetch or ['options'](https://www.npmjs.com/package/node-fetch#options) parameter of node-fetch. <br /><br />However two settings are MANDATORY: ***'timeout'*** to time-box a request and ***'maxRequests'*** to limit the total number of requests to attempt.<br /><br /> Other properties refer to ['init'](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters) of window.fetch or ['options'](https://www.npmjs.com/package/node-fetch#options) of node-fetch
| init | true |object | 2 properties are MANDATORY: ***'timeout'*** to time-box a single request and ***'maxRequests'*** to limit the total number of requests to attempt. <br /><br />Besides it can have on-demand properties in ['init'](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters) parameter of `window.fetch` or ['options'](https://www.npmjs.com/package/node-fetch#options) parameter of `node-fetch`. <br /> Please refer to link ['init'](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters) of window.fetch or ['options'](https://www.npmjs.com/package/node-fetch#options) of node-fetch
| callback | true |function | It will be invoked with a resolved promise(if a request is well finished before attempting all the retry requests) <br /> or with last request' result(a promise that might be eventually resolved or rejected)

@@ -94,0 +95,0 @@ | optLogger | false |function |Optional, if any, will get called with a single string parameter to give small hints when making request

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