Back to Content

AbortController: abort() method

files/en-us/web/api/abortcontroller/abort/index.md

latest1.0 KB
Original Source

{{APIRef("DOM")}}{{AvailableInWorkers}}

The abort() method of the {{domxref("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-nolint
abort()
abort(reason)

Parameters

  • reason {{optional_inline}}
    • : The reason why the operation was aborted, which can be any JavaScript value. If not specified, the reason is set to "AbortError" {{domxref("DOMException")}}.

Return value

None ({{jsxref("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

{{Specifications}}

Browser compatibility

{{Compat}}

See also