Skip to content
Merged
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
20 changes: 17 additions & 3 deletions src/pages/ContributorProfile/ContributorProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,28 @@ export default function ContributorProfile() {

try {
const userRes = await fetch(`https://api.github.com/users/${username}`);
if (!userRes.ok) {
if (userRes.status === 404) {
setProfile(null);
setPRs([]);
return;
}
throw new Error(`Failed to load user (${userRes.status})`);
}
const userData = await userRes.json();
setProfile(userData);
setProfile(userData as Profile);

const prsRes = await fetch(
`https://api.github.com/search/issues?q=author:${username}+type:pr`
);
const prsData = await prsRes.json();
setPRs(prsData.items);
if (!prsRes.ok) {
// avoid crashing — show empty PR list and notify user
setPRs([]);
toast.error("Failed to load pull requests.");
} else {
const prsData = await prsRes.json();
setPRs(prsData.items ?? []);
}
} catch {
toast.error("Failed to fetch user data.");
} finally {
Expand Down
Loading