fix: actually resolve the error from requests

This commit is contained in:
Paul Makles 2022-06-07 17:00:11 +01:00
parent 12b9716043
commit 67c8418c31

View file

@ -7,12 +7,12 @@ import { Children } from "../../types/Preact";
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
export function takeError(error: any): string { export function takeError(error: any): string {
if (error.response) { if (error.response) {
const status = error.response.status; const type = error.response.data?.type;
if (error.response.type) { if (type) {
return error.response.type; return type;
} }
switch (status) { switch (error.response.status) {
case 429: case 429:
return "TooManyRequests"; return "TooManyRequests";
case 401: case 401: