Complete the code to create a new AbortController instance.
const controller = new [1]();The AbortController is used to create a controller that can abort asynchronous tasks.
Complete the code to get the signal from the AbortController.
const signal = controller.[1];The signal property of the controller provides the signal to pass to async tasks for cancellation.
Fix the error in the code to abort the controller.
controller.[1]();The abort() method triggers the cancellation signal.
Fill both blanks to create a fetch request that can be aborted.
fetch(url, { signal: [1] }).then(response => response.[2]());The signal property is passed to fetch for cancellation, and json() parses the response body.
Fill all three blanks to handle abort error in a fetch request.
try { await fetch(url, { signal: [1] }); } catch (error) { if (error.[2] === '[3]') { console.log('Fetch aborted'); } }
The signal is passed to fetch. The error's name property is checked for 'AbortError' to detect cancellation.
