fix: handle http code 403

GitHub API doesn't return CORS headers when not ok
This commit is contained in:
EnixCoda 2020-04-08 23:14:29 +08:00
parent b9d4bfd07d
commit 012aa94a87
No known key found for this signature in database
GPG key ID: 0C1A07377913A1DD

View file

@ -39,6 +39,7 @@ async function request(
throw new Error(`Response content type is "${contentType}"`)
} else {
if (res.status === 404 || res.status === 401) throw new Error(errors.NOT_FOUND)
else if (res.status === 403) throw new Error(errors.API_RATE_LIMIT)
else if (res.status === 500) throw new Error(errors.SERVER_FAULT)
else if (isJson) {
const content = await res.json()