Welcome to node-fetch-timeout ????
A light-weight wrapper package built on awesome node-fetch package that adds timeout and retry option.
Install
npm install node-fetch-timeout
Usage
Using require
const { request } = require('node-fetch-timeout);
Using ES6 Modules
import { request } from 'node-fetch-timeout';
Using Promise Chain
request(url, {
...standardRequestHeaders,
timeout: 1, // timeout in milliseconds
retryCount: 3 // number of retires - defaults to 1
}).then(res => {
// res is raw response
// use res.json() or res.text()
console.log(res);
}).catch(err => {
console.log(err);
});
Using Latest Async/Await Syntax
try {
const res = await request(url, {
...standardRequestHeaders,
timeout: 1, // timeout in milliseconds
retryCount: 3 // number of retires - defaults to 1
});
// res is raw response
// use res.json() or res.text()
console.log(res)
} catch (error) {
console.log(error)
}
Author
???? Karan Raina karanraina1996@gmail.com
???? Contributing
Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.
Show your support
Give a ⭐️ if this project helped you!
This README was generated with ❤️ by readme-md-generator