One gap in the fetch example: fetch doesn't reject on a 404 or 500, so response.json() runs on the error body and setUser stores it. The page then renders an empty h1 instead of 'No user found'. Checking response.ok and throwing before parsing makes the catch branch cover real failures too.
Tarun Sharma
React.js Frontend Web Developer | Next.js Specialist
One gap in the fetch example: fetch doesn't reject on a 404 or 500, so response.json() runs on the error body and setUser stores it. The page then renders an empty h1 instead of 'No user found'. Checking response.ok and throwing before parsing makes the catch branch cover real failures too.