Web APIs
AbortController.prototype.abort()
Marks the associated signal aborted once and notifies listeners. Subsequent calls leave the existing abort reason unchanged.
Formal Syntax & Structure
javascript syntaxjavascript
controller.abort(reason)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| reason | any | Cancellation reason; omitted reason uses a host AbortError. |
Return Value
undefined
No return value.
Working Example
Example Snippetjavascript
const c = new AbortController();c.signal.addEventListener("abort", () => console.log(c.signal.reason), {once:true});c.abort("stop"); c.abort("again");console.log(c.signal.aborted);