From b24893541bb43e4b3eb86c29a3cbbb90b33efb6b Mon Sep 17 00:00:00 2001 From: viinz <42003446+dev-viinz@users.noreply.github.com> Date: Sun, 10 Apr 2022 19:23:08 +0200 Subject: [PATCH] fix: prevent crashing the rest process (#2159) * fix: prevent crashing the rest process There where instances where some requests crashed the rest process. I found that checking for a body pretty much fixed it. There is probably a better way to do this, please improve this if you have an idea :) * chore: use undefined instead of empty string Co-authored-by: LTS20050703 <87189679+lts20050703@users.noreply.github.com> * chore: use ternary operator Co-authored-by: LTS20050703 <87189679+lts20050703@users.noreply.github.com> --- template/bigbot/src/rest/mod.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/bigbot/src/rest/mod.ts b/template/bigbot/src/rest/mod.ts index 425153a30..08f9d8456 100644 --- a/template/bigbot/src/rest/mod.ts +++ b/template/bigbot/src/rest/mod.ts @@ -42,7 +42,7 @@ async function handleRequest(conn: Deno.Conn) { ); } - const json = (await requestEvent.request.json()); + const json = requestEvent.request.body ? (await requestEvent.request.json()) : undefined; try { const result = await rest.runMethod(