0
0
Node.jsframework~10 mins

AbortController for cancellation in Node.js - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new AbortController instance.

Node.js
const controller = new [1]();
Drag options to blanks, or click blank then click option'
APromise
BAbortSignal
CEventEmitter
DAbortController
Attempts:
3 left
💡 Hint
Common Mistakes
Using AbortSignal instead of AbortController.
Using Promise which is unrelated here.
2fill in blank
medium

Complete the code to get the signal from the AbortController.

Node.js
const signal = controller.[1];
Drag options to blanks, or click blank then click option'
Aabort
Bcancel
Csignal
Dcontroller
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'abort' which is a method, not a property.
Using 'cancel' which does not exist.
3fill in blank
hard

Fix the error in the code to abort the controller.

Node.js
controller.[1]();
Drag options to blanks, or click blank then click option'
Aabort
Bcancel
Cstop
Dend
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'cancel' which is not a method of AbortController.
Using 'stop' or 'end' which do not exist.
4fill in blank
hard

Fill both blanks to create a fetch request that can be aborted.

Node.js
fetch(url, { signal: [1] }).then(response => response.[2]());
Drag options to blanks, or click blank then click option'
Asignal
Bjson
Ctext
Dcontroller
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the controller instead of its signal.
Using 'text' instead of 'json' when expecting JSON data.
5fill in blank
hard

Fill all three blanks to handle abort error in a fetch request.

Node.js
try {
  await fetch(url, { signal: [1] });
} catch (error) {
  if (error.[2] === '[3]') {
    console.log('Fetch aborted');
  }
}
Drag options to blanks, or click blank then click option'
Asignal
Bname
CAbortError
Dmessage
Attempts:
3 left
💡 Hint
Common Mistakes
Checking error.message instead of error.name.
Passing controller instead of signal.