Skip to content

Commit b8a87eb

Browse files
committed
fix(contributors): handle 204 No Content to avoid JSON parse error
1 parent 949406a commit b8a87eb

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/pages/Contributors/Contributors.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ export default function Contributors() {
6969
token
7070
);
7171

72+
// Some repos return 204 No Content when there are no contributors.
73+
// res.ok is true for 204, but res.json() would throw; handle it explicitly.
74+
if (res.status === 204) {
75+
setContributors([]);
76+
return;
77+
}
78+
7279
if (!res.ok) {
7380
const txt = await res.text();
7481
throw new Error(`GitHub ${res.status}: ${txt}`);

0 commit comments

Comments
 (0)