An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

Welcome to node-fetch-timeout 👋




Version


Version


Documentation


License: ISC


Twitter: karankraina

> 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)_