AbortSignal.timeout()

A function that returns a signal which aborts itself after a given number of milliseconds, with a TimeoutError.

In more detail

The timer starts when the signal is created, and the abort reason is a DOMException named TimeoutError. fetch(url, { signal: AbortSignal.timeout(5000) }) gives up after five seconds without writing any timer code.

Related terms

Taught in

References