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.
abort()
abort(reason)reason OptionalThe reason why the operation was aborted, which can be any JavaScript value. If not specified, the reason is set to "AbortError" DOMException.
None (undefined).
See the AbortSignal page for usage examples.
You can find a full working example on GitHub; you can also see it running live.