[+] Failure
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@
|
||||
let error: string | null = null;
|
||||
|
||||
if (!puzzleId) window.location.href = "/?puzzle=meow";
|
||||
else Backend.get(puzzleId).then((data) => (puzzleData = data)).catch((e) => (error = e));
|
||||
else Backend.get(puzzleId).then((data) => (puzzleData = data)).catch(e => (error = e));
|
||||
</script>
|
||||
|
||||
{#if puzzleData !== null && puzzleId !== null}
|
||||
|
||||
+4
-1
@@ -71,6 +71,9 @@ export const Fmt = {
|
||||
}
|
||||
|
||||
export const Backend = {
|
||||
get: (id: string) => fetch(`${cfg.backend}/${id}`).then(r => r.text()).then(JsonTy.parse),
|
||||
get: (id: string) => fetch(`${cfg.backend}/${id}`).then(r => {
|
||||
if (!r.ok) throw new Error(`Failed to get puzzle: ${r.status}`)
|
||||
r.text()
|
||||
}).then(JsonTy.parse),
|
||||
post: (data: Checkpoint) => fetch(`${cfg.backend}/`, { method: "post", body: JsonTy.stringify(data) }),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user