AbortController
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2019.
Note: This feature is available inWeb Workers.
TheAbortController interface represents a controller object that allows you to abort one or more Web requests as and when desired.
You can create a newAbortController object using theAbortController() constructor. Communicating with an asynchronous operation is done using anAbortSignal object.
In this article
Constructor
AbortController()Creates a new
AbortControllerobject instance.
Instance properties
AbortController.signalRead onlyReturns an
AbortSignalobject instance, which can be used to communicate with, or to abort, an asynchronous operation.
Instance methods
AbortController.abort()Aborts an asynchronous operation before it has completed. This is able to abortfetch requests, consumption of any response bodies, and streams.
Examples
See theAbortSignal page for usage examples.
You can find afull working example on GitHub; you can also see itrunning live.
Specifications
| Specification |
|---|
| DOM> # interface-abortcontroller> |
Browser compatibility
See also
- Fetch API
- Abortable Fetch by Jake Archibald