Skip to content

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

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions