JavaScript · Middle · Question 38 of 75

Will fetch reject the promise on a 404 response?

Explanation

An HTTP error response is still a response. You need an explicit check: if (!res.ok) throw new Error(res.status). The promise rejects on network failure, CORS blocking or cancellation via AbortController.

Further reading

Problem with a question

JavaScript · Middle · question 38

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