web api interface
AbortController
Available in workers
The AbortController interface represents a controller object that allows you to abort one or more Web requests as and when desired.
You can create a new AbortController object using the AbortController() constructor. Communicating with an asynchronous operation is done using an AbortSignal object.
Constructor
AbortController()- : Creates a new
AbortControllerobject instance.
- : Creates a new
Instance properties
signalRead only- : Returns an
AbortSignalobject instance, which can be used to communicate with, or to abort, an asynchronous operation.
- : Returns an
Instance methods
abort()- : Aborts an asynchronous operation before it has completed. This is able to abort fetch requests, consumption of any response bodies, and streams.
Examples
See the AbortSignal page for usage examples.
You can find a full working example on GitHub; you can also see it running live.
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.
See also
- Fetch API
- Abortable Fetch by Jake Archibald