node-fetch-timeout
v1.0.2
Published
Wrapper package for node-fetch package that adds timeout and retry option.
Downloads
3
Maintainers
Readme
A light-weight wrapper package built on awesome node-fetch package that adds timeout and retry option.
🏠 Homepage
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 [email protected]
- Website: https://karanraina.tech
- Twitter: @karankraina
- Github: @karankraina
- LinkedIn: @karankraina
🤝 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