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

https://github.com/muke1908/promisewithtimeout

Early reject a promise with a timeout
https://github.com/muke1908/promisewithtimeout

Last synced: about 1 year ago
JSON representation

Early reject a promise with a timeout

Awesome Lists containing this project

README

          

# promiseWithTimeout
Reject a promise early with timeout. In this example the promise will be rejected if the API doesn't return respose within 280ms.

```
const fetchProduct = fetch('https://fakestoreapi.com/products/1').then(res => res.json());

(async (){
try{
const products = await new PromiseWithTimeOut(fetchProduct, 280);
console.log({ products });
}catch(err){
console.log('err', err)
}
})()
```