- From: Jake Archibald <notifications@github.com>
- Date: Mon, 21 Aug 2017 13:11:08 +0000 (UTC)
- To: whatwg/fetch <fetch@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Monday, 21 August 2017 13:11:31 UTC
Using the abort syntax, you'll be able to do:
```js
const controller = new AbortController();
const signal = controller.signal;
const fetchPromise = fetch(url, {signal});
// 5 second timeout:
const timeoutId = setTimeout(() => controller.abort(), 5000);
const response = await fetchPromise;
// …
```
If you only wanted to timeout the request, not the response, add:
```js
clearTimeout(timeoutId);
// …
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/20#issuecomment-323740783
Received on Monday, 21 August 2017 13:11:31 UTC