Adds retry functionality to window.fetch polyfill (whatwg-fetch).
- Retry count
- Retry delay
- Timeout (total of retries)
ECMAScript 2015
$ npm install window-fetch-retry --save
import fetch from 'window-fetch-retry';
fetch('/users.json', {
retries: 3,
retryDelay: 1000,
timeout: 3000,
})
.then(res => res.json())
.then((json) => {
console.log('parsed json', json);
}).catch((ex) => {
console.log('parsing failed', ex);
});