fetch-with-timeout
v1.0.1
Published
Fetch with timeout.
Downloads
95
Maintainers
Readme
fetch-with-timeout
The fetch API started out as a target for criticism because of lack of timeout and request cancelation. While those criticisms could be argued as fair or not, the you can't deny that the fetch API has been pretty awesome. As we've always done, if a feature is missing, we can always shim it in.
Usage
npm install --save fetch-with-timeout
// ES5
var fetchWithTimeout = require('fetch-with-timeout');
// ES6
import fetchWithTimeout from 'fetch-with-timeout';
/**
* fetch-with-timeout
* @param domain (required)
* @param options same as fetch options
* @param timeout fetch's timeout
* @returns Promise
*/
fetchWithTimeout(domain, [options], [timeout])
.then(function(res) {
console.log(res);
})
.catch(function(err) {
console.error(err);
});
Contributing
Pull requests and suggestions are more than welcome!