Request: signal property
The signal property is the AbortSignal used to cancel this request.
Value
An AbortSignal.
- Read-only; assigning to it throws
TypeError. - When a
signalwas given at construction, it's that very object. - When none was given, it's an
AbortSignalthat's never aborted, and every read returns the same object. - After this
Requestis passed tofetch(), abortingsignalcancels the request.
Examples
js
const controller = new AbortController();
const req = new Request('https://httpbin.org/get', { signal: controller.signal });
console.log(req.signal === controller.signal);Result: Prints true.
Differences from the web
On the web, req.signal is a separately created object that follows the signal given at construction, so req.signal === controller.signal is false. In Nacre it's the very signal given at construction, so it's true.