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.5 to 1.0.6

6

index.js
/**
@param url, string, resource destination url to make request to, the fetch request will be delegated to either window.fetch(when use in browser) or npm module node-fetch(when use in node server side).
@param url, string, resource destination url to make request to, the fetch request will be delegated either to window.fetch(when use in browser) or npm module node-fetch(when use in node server side).
@param init, object, can have properties in 'init' parameter of window.fetch api(https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)

@@ -150,4 +150,4 @@ or in 'options' parameter of node-fetch library (https://www.npmjs.com/package/node-fetch#options)

const isBrowser = new Function("try {return this===window;}catch(e){ return false;}");
const fetcher = (isBrowser() && window && window.fetch) || require('node-fetch');
const isBrowser = new Function("try {return window && this===window;}catch(e){ return false;}");
const fetcher = (isBrowser() && window.fetch) || require('node-fetch');

@@ -154,0 +154,0 @@ return () => fetcher(url, init);

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

@@ -6,0 +6,0 @@ "type": "git",

<h1 align="center">Robust Http Fetch</h1>
<p align="center">
<a href="https://www.npmjs.com/package/robust-http-fetch">
<img src="https://img.shields.io/badge/npm-v1.0.5-blue" />
<img src="https://img.shields.io/badge/npm-v1.0.6-blue" />
</a>

@@ -16,3 +16,3 @@ <a href="https://github.com/gaoqing/robust-http-fetch/blob/master/LICENSE">

This robust-http-fetch is a light-weight and [100%-test-coverage](https://codecov.io/gh/gaoqing/robust-http-fetch) javascript util for robustly making 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 for robustly making http fetch request.

@@ -23,3 +23,3 @@ The underlying fetch will be delegated to either [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 side.

***Caveat***: 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.
***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.
as well as DELETE. In case of POST/PUT, make sure your server side(or rely on DB constraints etc) to maintain the integrity, for example backend to perform checking if previous requests have completed then abort duplicated requests etc.

@@ -37,3 +37,3 @@

Usage is as simple as below, can also refer to tests in [End2End tests](https://github.com/gaoqing/robust-http-fetch/blob/master/test/e2e.test.js) or [unit tests](https://github.com/gaoqing/robust-http-fetch/blob/master/test/index.test.js))
Usage is as simple as below, can refer to tests in [End2End tests](https://github.com/gaoqing/robust-http-fetch/blob/master/test/e2e.test.js) or [unit tests](https://github.com/gaoqing/robust-http-fetch/blob/master/test/index.test.js))

@@ -46,3 +46,4 @@ ```javascript

//Here use the Promise resolve callback function as the callback in 3rd parameter, but you can use any function as callback to fit yourself
//here use the Promise resolve callback function as the callback in 3rd parameter,
//but you can use any callback function which accept a Promise object as its argument.
const resultAsPromise = new Promise((resolve, reject) => {

@@ -52,4 +53,4 @@ robustHttpFetch(

{
timeout: 3000, // required, ie. here request will wait 1500ms before firing another request
maxRequests: 3, // required, ie. here upto 3 requests to fire in case previous requests delayed or not resolved happily
timeout: 3000, // required, ie. here request will wait 3000ms before firing another request
maxRequests: 3, // required, ie. here upto 3 requests to fire in case previous requests delayed or not well resolved
method: 'POST',

@@ -72,3 +73,3 @@ body: JSON.stringify(body),

```const {robustHttpFetch} = require('robust-http-fetch')``` is a javascript function to use, which accept 4 parameters as following
```const {robustHttpFetch} = require('robust-http-fetch')``` robustHttpFetch is a javascript function to use, which accept 4 parameters as following

@@ -75,0 +76,0 @@

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