Skip to content

Commit 8698f1a

Browse files
committed
fix: array warnings
1 parent debaa77 commit 8698f1a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/lib/api/fetchGitHistory.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ async function fetchWithRateLimit(
3838
continue
3939
}
4040

41-
return await response.json()
41+
if (!response.ok) throw new Error(response.statusText)
42+
const json = await response.json()
43+
if (!Array.isArray(json)) {
44+
console.warn("Unexpected response from GitHub API", json)
45+
return []
46+
}
47+
return json
4248
}
4349
}
4450

@@ -59,6 +65,7 @@ export const fetchAndSaveGitHistory = async (mdDir: string) => {
5965
(await fetchWithRateLimit(
6066
filepath.replace(CONTENT_DIR, OLD_CONTENT_DIR)
6167
)) || []
68+
6269
// Transform commitHistory
6370
const contributors = [...history, ...legacyHistory]
6471
.filter(({ author }) => !!author)

0 commit comments

Comments
 (0)