robust-http-fetch
Advanced tools
Comparing version 1.1.11 to 1.1.12
@@ -120,5 +120,7 @@ /** | ||
function getLogger(optLogger) { | ||
const logger = typeof optLogger === 'function' ? optLogger : (ignored) => { | ||
}; | ||
return (args) => logger(new Date().toISOString() + ': ' + args); | ||
if (typeof optLogger !== 'function') { | ||
return (ignored) => { | ||
}; | ||
} | ||
return (args) => optLogger(new Date().toISOString() + ': ' + args); | ||
} | ||
@@ -125,0 +127,0 @@ |
{ | ||
"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.1.11", | ||
"version": "1.1.12", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
@@ -45,3 +45,3 @@ <h1 align="center">Robust Http Fetch</h1> | ||
```javascript | ||
const robustHttpFetchAsPromise = require('robust-http-fetch'); | ||
const robustHttpFetch = require('robust-http-fetch'); | ||
@@ -54,10 +54,11 @@ const url = "https://postman-echo.com/post"; | ||
* @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 console.log, optional function, any function accept a string argument | ||
* @input init object, required, sample properties | ||
* {timeout}, required, below example will wait 3000ms before firing retry request | ||
* {maxRequests}, required, below example upto 3 requests to fire in case previous requests delayed or not well resolved | ||
* {method/body/headers}...and more, on demand properties, usage refer to `window.fetch`(init config)/`node-fetch`(options config) | ||
* @input optional function, any function accept a string argument, below example, use console.log | ||
* | ||
* @return a promise resolved with a positive result or a rejected promise if eventually failed | ||
**/ | ||
const resultPromise = robustHttpFetchAsPromise(url, { | ||
const resultPromise = robustHttpFetch(url, { | ||
timeout: 3000, | ||
@@ -81,3 +82,3 @@ maxRequests: 3, | ||
```const robustHttpFetchAsPromise = require('robust-http-fetch')```, it is a javascript function to use, which accept 3 parameters as followings | ||
```const robustHttpFetch = require('robust-http-fetch')```, it is a javascript function to use, which accept 3 parameters as followings | ||
@@ -84,0 +85,0 @@ |
14807
153
105