JavaScript 2025 · Promises and fetch
Time out a request
Abort a request that takes longer than five seconds.
const res = await fetch(url, { signal: AbortSignal.timeout(5000) });
Official JavaScript 2025 documentation
More promises and fetch commands
- Fetch JSON
- POST JSON
- Handle errors in async code
- Run promises in parallel
- Wait for all promises, whatever happens
- Pause for a while
All promises and fetch commands · JavaScript 2025 cheatsheet