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

All promises and fetch commands · JavaScript 2025 cheatsheet

Was this page helpful?