Skip to content

πŸ› Bug Report: Check API Response Errors in Activity FeedΒ #637

@annrose2277-glitch

Description

@annrose2277-glitch

πŸ“œ Description

Problem
// ❌ No status validation - treats errors as events
const res = await fetch(https://api.github.com/users/${username}/events);
const data = await res.json();
setEvents(data); // Could be error object!

Solution
// βœ… Validate response before parsing
const res = await fetch(https://api.github.com/users/${username}/events);
if (res.ok) {
const data = await res.json();
setEvents(data);
} else {
setEvents([]);
console.error("Failed to fetch events");
}

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