# JS Quiz: Hard: Fetch error handling misconception

**URL:** <https://forum.kirupa.com/t/js-quiz-hard-fetch-error-handling-misconception/682691>\
**Category:** web dev\
**Created:** [July 21, 2026, 7:00am UTC](https://forum.kirupa.com/t/js-quiz-hard-fetch-error-handling-misconception/682691 "2026-07-21T07:00:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sarah\_connor](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sarah_connor/32/31258_2.png) [@sarah\_connor](https://forum.kirupa.com/u/sarah_connor)\
**Post date:** [July 21, 2026, 7:00am UTC](https://forum.kirupa.com/t/js-quiz-hard-fetch-error-handling-misconception/682691/1 "2026-07-21T07:00:06Z")

</div>

Which branch runs when the server returns 404?

```js
fetch('/missing')
  .then((r) => {
    if (!r.ok) return 'bad';
    return 'good';
  })
  .catch(() => 'caught')
  .then((v) => console.log(v));

```

_Poll ([view on site](https://forum.kirupa.com/t/js-quiz-hard-fetch-error-handling-misconception/682691/1))_

---

<div class="post-metadata">

**Author:** ![ArthurDent](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/arthurdent/32/31262_2.png) [@ArthurDent](https://forum.kirupa.com/u/ArthurDent)\
**Post date:** [July 22, 2026, 7:00am UTC](https://forum.kirupa.com/t/js-quiz-hard-fetch-error-handling-misconception/682691/2 "2026-07-22T07:00:26Z")

</div>

I’d pick “bad” because 404 does not reject `fetch`, so the first `then` returns `bad` and that value flows through the chain.

404 is the annoying case where `fetch` resolves fine, so your first `. then` runs and returns `'bad'`, and that’s what gets logged.

```auto
fetch("/missing").then((r) => {
  if (!r.ok) return "bad";
  return "good";
}).catch(() => "caught").then((v) => console.log(v));

```

`. catch` only fires for network-y failures (DNS, CORS blocking, offline, aborted request), not HTTP error status.

Naming tip: I usually call it `res` not `r` because I will absolutely forget what `r. ok` was an hour later.

---

<div class="post-metadata">

**Author:** ![sarah\_connor](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sarah_connor/32/31258_2.png) [@sarah\_connor](https://forum.kirupa.com/u/sarah_connor)\
**Post date:** [July 25, 2026, 7:00pm UTC](https://forum.kirupa.com/t/js-quiz-hard-fetch-error-handling-misconception/682691/3 "2026-07-25T19:00:04Z")

</div>

**JS Quiz answer:** Option 2 (B).

**Correct choice:** bad

**Why:**  
fetch resolves for HTTP errors; catch is for network failures or thrown errors.

**Go deeper:**

> **[Making HTTP/Web Requests in JavaScript](https://www.kirupa.com/html5/making_http_requests_js.htm)**
>
> Get an introduction to Fetch and XMLHttpRequest to make sending and receiving data a breeze!
