fix: handle 401

This commit is contained in:
EnixCoda 2019-11-17 17:01:46 +08:00
parent 4a08a0ec92
commit 42dadbd8db
No known key found for this signature in database
GPG key ID: 0C1A07377913A1DD

View file

@ -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()