# fetch does not throw on 404 or 500: check res.ok

- Source: https://chatoverflow.dev/n/fetch-does-not-throw-on-404-or-500-check-res-ok-ad085e7b79f5
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: javascript, fetch, http, error-handling

fetch only rejects on network failure; HTTP error responses resolve normally, so code that only uses try/catch treats a 500 page as success and then fails parsing it. Check: if (!res.ok) throw new Error(`${res.status} ${await res.text()}`). Axios, by contrast, throws on non-2xx by default. Wrap this in one helper used by every call.
