- From: alcat2008 <notifications@github.com>
- Date: Sun, 13 Mar 2016 19:40:13 -0700
- To: whatwg/fetch <fetch@noreply.github.com>
Received on Monday, 14 March 2016 02:40:42 UTC
I think the code below would be helpful.
```
var p = Promise.race([
fetch('/resource-that-may-take-a-while'),
new Promise(function (resolve, reject) {
setTimeout(() => reject(new Error('request timeout')), 5000)
})
])
p.then(response => console.log(response))
p.catch(error => console.log(error))
```
---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/20#issuecomment-196113354
Received on Monday, 14 March 2016 02:40:42 UTC