JavaScript · Middle · Question 39 of 75

How do you cancel a fetch request?

Explanation

After abort(), the promise rejects with an AbortError. The same signal can be passed to several requests and to addEventListener. For a timeout there's AbortSignal.timeout(5000). Promises have no cancel method.

Further reading

Problem with a question

JavaScript · Middle · question 39

Test yourself

Take the JavaScript · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz