https://github.com/karankraina/node-fetch-timeout
A light-weight wrapper package built on awesome node-fetch package that adds timeout and retry option.
https://github.com/karankraina/node-fetch-timeout
http-request node-fetch node-fetch-retry node-fetch-timeout request
Last synced: 10 days ago
JSON representation
A light-weight wrapper package built on awesome node-fetch package that adds timeout and retry option.
- Host: GitHub
- URL: https://github.com/karankraina/node-fetch-timeout
- Owner: karankraina
- Created: 2021-12-16T15:21:46.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-08-01T08:10:41.000Z (over 3 years ago)
- Last Synced: 2025-12-13T03:56:13.717Z (2 months ago)
- Topics: http-request, node-fetch, node-fetch-retry, node-fetch-timeout, request
- Language: JavaScript
- Homepage:
- Size: 185 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
Welcome to node-fetch-timeout 👋
> A light-weight wrapper package built on awesome [node-fetch](https://github.com/node-fetch/node-fetch) package that adds timeout and retry option.
### 🏠 [Homepage](https://github.com/karankraina/node-fetch-timeout)
## Install
```sh
npm install node-fetch-timeout
```
## Usage
### Using require
```sh
const { request } = require('node-fetch-timeout);
```
### Using ES6 Modules
```sh
import { request } from 'node-fetch-timeout';
```
### Using Promise Chain
```sh
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
```sh
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 **
* Website: https://karanraina.tech
* Twitter: [@karankraina](https://twitter.com/karankraina)
* Github: [@karankraina](https://github.com/karankraina)
* LinkedIn: [@karankraina](https://linkedin.com/in/karankraina)
## 🤝 Contributing
Contributions, issues and feature requests are welcome!
Feel free to check [issues page](https://github.com/karankraina/node-fetch-timeout/issues). You can also take a look at the [contributing guide](https://github.com/karankraina/node-fetch-timeout/blob/master/CONTRIBUTING.md).
## Show your support
Give a ⭐️ if this project helped you!
***
_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_