AbortController: abort() method
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 in Web Workers.
The abort()
method of the AbortController
interface aborts an asynchronous operation before it has completed.
This is able to abort fetch requests, the consumption of any response bodies, or streams.
Syntax
js
abort()
abort(reason)
Parameters
reason
Optional-
The reason why the operation was aborted, which can be any JavaScript value. If not specified, the reason is set to "AbortError"
DOMException
.
Return value
None (undefined
).
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
Specification |
---|
DOM> # ref-for-dom-abortcontroller-abortcontroller①> |
Browser compatibility
Loading…