From 47a029babaee916955579981deaac7bc2ec97b25 Mon Sep 17 00:00:00 2001 From: wont-stream Date: Wed, 15 Jan 2025 13:06:56 -0500 Subject: [PATCH] Handle error response for repository fetching in getTopLangs function --- index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 75ee679..97d2274 100644 --- a/index.ts +++ b/index.ts @@ -17,7 +17,11 @@ if (process.env.AuthorizationHeaderToken) { const getTopLangs = async (type: "users" | "orgs", name: string) => { const obj: Record = {} const repoResp = await fetch(`https://git.creations.works/api/v1/${type}/${name}/repos?limit=0`, fetchOpts); - const repos = await repoResp.json() as repos; + const repos = await repoResp.json() as repos | { message: string }; + + if ("message" in repos) { + throw new Error(repos.message); + } for (const repo of repos) { const lang = repo.language;