Skip to content

Commit

Permalink
catch error-responses
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Flick committed Jun 12, 2024
1 parent 6f95233 commit f6a3d3f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/routes/textzeugen/[[sigla]]/[[thirties]]/[[verse]]/+page.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,22 @@ export async function load({ fetch, params }) {
} else {
returnObject = data[witnes][0];
}
returnObject.iiif = fetch(returnObject.iiif).then((res) => res.json());
returnObject.iiif = fetch(returnObject.iiif).then((res) => {
if (!res.ok) {
console.error('Failed to fetch iiif', res);
return false;
}
return res.json();
});
returnObject.tpData = fetch(
`${teipb}/parts/${witnes}.xml/json?&view=page&id=${returnObject.id}&odd=parzival.odd`
).then((r) => r.json());
).then((r) => {
if (!r.ok) {
console.error('Failed to fetch tpData', r);
return false;
}
return r.json();
});
return returnObject
? { tpData: returnObject.tpData, iiif: returnObject.iiif, page: returnObject.id }
: { tpData: false, iiif: false, page: false };
Expand Down

0 comments on commit f6a3d3f

Please sign in to comment.