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

Do not report HTTP failures as an empty feed.

When res.ok is false, the error reaches the catch block, which only clears loading. If events is empty, the component renders No activity found for a failed request. Add an error state and render a failure message instead. Add a regression test in src/components/ActivityFeed.test.tsx for a non-OK response.

🤖 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 ActivityFeed’s
fetch flow to track request errors separately from the events list: when res.ok
is false, set the error state and render a failure message instead of “No
activity found,” while preserving loading cleanup. Add a regression case in
ActivityFeed.test.tsx covering a non-OK response and asserting the failure
message is shown.


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