Skip to content

πŸ› Bug Report: Missing HTTP Response Status CheckΒ #639

@annrose2277-glitch

Description

@annrose2277-glitch

πŸ“œ Description

Problem
// ❌ PROBLEMATIC CODE
const userRes = await fetch(https://api.github.com/users/${username});
const userData = await userRes.json(); // No check if response was successful
setProfile(userData);

Issue: The code doesn't check if the HTTP response status is OK (200-299). If GitHub API returns 404 or other error status, .json() will try to parse an error response, causing incorrect data to be set.

Impact: Silent failures, incorrect data display, poor user experience.

Recommended Fix: Add response status validation before parsing JSON.

What browsers are you seeing the problem on?

No response

πŸ“ƒ Relevant Screenshots (Links)

No response

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions