From 359acbf385446c36b41fc67d95495c1d704a7d0e Mon Sep 17 00:00:00 2001 From: Gabriel Simmer Date: Thu, 7 Jul 2022 18:09:12 +0100 Subject: [PATCH] Catching instances of null returned from backend --- src/routes/servers/[id]/index.svelte | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/routes/servers/[id]/index.svelte b/src/routes/servers/[id]/index.svelte index 67e4d80..ddeba67 100644 --- a/src/routes/servers/[id]/index.svelte +++ b/src/routes/servers/[id]/index.svelte @@ -18,12 +18,18 @@ } const r2 = await fetch(`/api/v1/server/${id}/invites`); - if (request.ok) { - invites = await r2.json(); + if (r2.ok) { + const a = await r2.body(); + if (a != "null") { + invites = await r2.json(); + } for (let invite in invites) { const logsReq = await fetch(`/api/v1/invite/${invites[invite].token}/log`) - if (request.ok) { - invites[invite]["log"] = await logsReq.json() + if (logsReq.ok) { + const b = await logsReq.body(); + if (b != "null") { + invites[invite]["log"] = await logsReq.json() + } } } } else {