Skip to content

πŸ› Bug Report: Improve HTTP Status Handling in Profile Fetch ⭐ RECOMMENDEDΒ #636

@annrose2277-glitch

Description

@annrose2277-glitch

πŸ“œ Description

Problem

// ❌ No status check - crashes on 404
const userRes = await fetch(https://api.github.com/users/${username});
const userData = await userRes.json();
setProfile(userData);

Solution
// βœ… Check response status first
const userRes = await fetch(https://api.github.com/users/${username});
if (userRes.ok) {
const userData = await userRes.json();
setProfile(userData);
} else {
toast.error("User not found or API error");
}

What browsers are you seeing the problem on?

No response

πŸ“ƒ Relevant Screenshots (Links)

@GitMetricsLab
/assign
Hi! I'm a first-year CS student looking to dive deeper into open source, and I'd love to take this on. I can update the fetch logic to verify userRes.ok first, ensuring we handle non-200 responses gracefully with a toast error instead of crashing on a 404. Could you assign this to me?

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