fetch only rejects on network errors, not HTTP errors like or . Check response.ok for success.
const response = await fetch(url);
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const data = await response.json();
Always check the response status before parsing the body.