static: make SiteShell redirect when request > 400

This commit is contained in:
Jens Langhammer 2020-11-24 23:06:20 +01:00
parent 7c73d2c2fb
commit 43f27c2401
3 changed files with 10 additions and 2 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -54,6 +54,14 @@ export class SiteShell extends LitElement {
} }
this.loading = true; this.loading = true;
fetch(this._url) fetch(this._url)
.then((r) => {
if (r.ok) {
return r;
}
console.log(`passbook/site-shell: Request failed ${this._url}`);
window.location.hash = "#/";
throw new Error("Request failed");
})
.then((r) => r.text()) .then((r) => r.text())
.then((t) => { .then((t) => {
this.querySelector("[slot=body]")!.innerHTML = t; this.querySelector("[slot=body]")!.innerHTML = t;