π 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?
π 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?