Classic trap: fetch only rejects on network problems (offline, DNS, CORS block). An HTTP 404/500 still fulfills with a Response where ok is false. Throw yourself when !response.ok.

Results appear here.

Compare fulfill + !ok versus promise rejection.

Important JavaScript

async function getPost(id) {
  const response = await fetch(
    "https://jsonplaceholder.typicode.com/posts/" + id
  );
  if (!response.ok) {
    throw new Error("HTTP " + response.status);
  }
  return response.json();
}