Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const app = express();
const allowedOrigins = ['http://localhost:5173', 'https://github-spy.etlify.app'];
app.use(cors({
origin: function (origin, callback) {
if (!origin || allowedOrigins.indexOf(origin) !== -1) {
if (!origin || allowedOrigins.includes(origin)) {
callback(null, true);
} else{
callback(new Error('Blocked by CORS policy'));
Expand Down
3 changes: 2 additions & 1 deletion src/components/ActivityFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export default function ActivityFeed({ username }: { username: string }) {
const res = await fetch(
`https://api.github.com/users/${username}/events`
);
const data = await res.json();
if (!res.ok) throw new Error("Request failed");
const data = await res.json();
Comment on lines +36 to +37

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Show an error state for failed responses.

When res.ok is false, the catch block only stops loading. The UI then shows No activity found on the initial request, or silently displays stale events during a refresh. Add an error state and render it instead of treating a failed request as an empty successful response. Add tests for both initial and interval-fetch failures.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/ActivityFeed.tsx` around lines 36 - 37, Update the
ActivityFeed request flow to track a distinct error state when the response is
not OK or parsing fails, and clear it on successful fetches. Render the error
state instead of “No activity found” or stale events after failures, and add
coverage for both initial-load and interval-fetch failures.


setEvents(data);
setLoading(false);
Expand Down
Loading