1.0.2 ā¢ Published 2 years ago
node-fetch-timeout v1.0.2
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 karanraina1996@gmail.com
- 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