Why does fetch() resolve when the server returns HTTP 404?

Fetch can successfully deliver a Response with status 404. The server answered the request, so the Promise can resolve even though the resource is missing. Inspect response.ok and response.status before treating the body as successful data.
Decide how the caller should use a 404. A lookup feature may show a missing-record state, while another API client may throw an application error for non-success statuses. The example makes that choice explicit after logging the status.
const response = await fetch('/missing-page'); console.log(response.ok, response.status); // false, typically 404 if (!response.ok) throw new Error(`Request failed: ${response.status}`);
Compare a missing route with a failed connection. The missing route gives the caller a Response and a status to handle. A connection failure can leave it with only a rejection, so the interface needs a separate path for that case.
Call a known missing route and compare its Response object with what you get from a simulated network failure.