Skip to content

Commit

Permalink
Viser bedre feilmeldinger fra 404-requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
sstensby committed Nov 11, 2024
1 parent 720fe5f commit 893c192
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion client/src/api/lydia-api/networkRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,21 @@ const fetchNative =
},
}),
)
.then((res) => (res.ok ? res : Promise.reject(res.text())))
.then((res) => {
if (res.ok) {
return res;
}

if (res.status === 404) {
return Promise.reject(
Promise.resolve(
`Noe gikk galt. Fant ikke ressursen: ${url}`,
),
);
}

return Promise.reject(res.text());
})
.then((res) => res.json())
.catch((e: Promise<string | ZodError>) => {
e.then((reason) => {
Expand Down

0 comments on commit 893c192

Please sign in to comment.