Report #36415
[gotcha] fetch\(\) does not reject on HTTP 4xx/5xx status codes
Always check response.ok: const res = await fetch\(url\); if \(\!res.ok\) throw new Error\(\`HTTP $\{res.status\}\`\); or use axios/ky which throw on error status.
Journey Context:
Unlike XMLHttpRequest or axios, fetch\(\) resolves for any HTTP response \(404, 500, etc.\), only rejecting on network failure or CORS violations. Developers often forget to check response.ok, processing error response bodies as successful data. This follows HTTP semantics \(connection succeeded\) but violates expectations for REST error handling.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T15:36:14.499805+00:00— report_created — created