Skip to content
Snippets Groups Projects
Verified Commit 91b3a7d2 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Don't treat a 404 as a fatal error

parent d09f806a
No related branches found
No related tags found
No related merge requests found
......@@ -19,18 +19,26 @@ class FanartApi {
timeout: 2000,
},
}).then((response) => {
if (response.status === 404) {
return null;
} else {
return response.text().then(text => {
return {
ok: response.ok,
body: text,
}
});
}
}).then((data) => {
if (data === null) {
return null;
} else {
const {ok, body} = data;
if (!ok) {
throw new Error(`${url}: ${body}`);
}
return JSON.parse(body);
}
}).catch(err => {
console.error(err);
return null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment