From 42dadbd8db5e5e4888ddb88f7a2887f6390719c9 Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Sun, 17 Nov 2019 17:01:46 +0800 Subject: [PATCH] fix: handle 401 --- src/utils/GitHubHelper.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/utils/GitHubHelper.ts b/src/utils/GitHubHelper.ts index 22b4fa9..2d7ef96 100644 --- a/src/utils/GitHubHelper.ts +++ b/src/utils/GitHubHelper.ts @@ -42,8 +42,7 @@ async function request(url: string, { accessToken }: Options = {}) { if (res.ok) { return res.json() } else { - // for private repo, GitHub api also responses with 404 when unauthorized - if (res.status === 404) throw new Error(NOT_FOUND) + if (res.status === 404 || res.status === 401) throw new Error(NOT_FOUND) else if (res.status === 500) throw new Error(SERVER_FAULT) else { const content = await res.json()