JavaScript 2025 · Promises and fetch
Pause for a while
A promise that resolves after a delay.
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
await sleep(1000);
Official JavaScript 2025 documentation
More promises and fetch commands
- Fetch JSON
- POST JSON
- Time out a request
- Handle errors in async code
- Run promises in parallel
- Wait for all promises, whatever happens
All promises and fetch commands · JavaScript 2025 cheatsheet