0.2.0 • Published 2 years ago

node-fetch-backoff v0.2.0

Weekly downloads
228
License
MIT
Repository
github
Last release
2 years ago

Basic usage example

Build Status Coverage Status

const nfbFactory = require('node-fetch-backoff');
const fetch = nfbFactory({
    // Msec or function. Default is exponential delay using msec from this option.
    delay: 10 * 1000,

    // Default is 5 retries before giving up
    retries: 5,

    // Default is a function that reads the ok property of the response object.
    // The function gets passed the response.
    isOK: (resp) => resp.ok,

    // Function that gets the error passed in to deside if it should retry.
    shouldRetryError: (error) => true,

    // Function that gets the response passed in to deside if it should retry.
    shouldRetryResponse = () => true,

    // The fetch implementation to use. If not provided it will require node-fetch.
    fetch: undefined,
});

// Follows the https://www.npmjs.com/package/node-fetch implementation.
const res = await fetch('/test.json');
0.2.0

2 years ago

0.1.0

3 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago