HTTP and REST APIs

Lesson 05 · 10 min

fetch and errors on the client

fetch doesn't throw on a 404. Checking res.ok is your job.

10 minLesson 5 of 9Practice includedAsk AI on any point

fetch returns a Promise with the response. It only rejects when there's no network at all. A 404 or 500 is a successful delivery of bad news, so you check res.ok (status 200–299) yourself.

Sign in to continue

The rest of this lesson opens after sign up

The first lesson of every course is open without an account. To read on, solve the practice and use Ask, create a free account or log in.