AbortController

AbortController lets you cancel asynchronous operations such as a fetch request. You create a controller, pass its signal to fetch, then call abort(): the promise is rejected with an AbortError. It is used for timeouts and to ignore responses that have become useless.

Example

const c = new AbortController()
fetch(url, { signal: c.signal })
c.abort()

Related concepts

The whole glossary