From 3a105c79dda488c887d2c43bcb4ead57d2531fdb Mon Sep 17 00:00:00 2001 From: waltem01 Date: Thu, 30 Nov 2023 09:19:07 +0100 Subject: [PATCH] clean up --- Webserver/src/routes/api/redirect/+server.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Webserver/src/routes/api/redirect/+server.ts b/Webserver/src/routes/api/redirect/+server.ts index 272271b..b437426 100644 --- a/Webserver/src/routes/api/redirect/+server.ts +++ b/Webserver/src/routes/api/redirect/+server.ts @@ -2,11 +2,9 @@ import type { APIResponse } from "$lib/interfaces"; import { json, type RequestHandler } from "@sveltejs/kit"; export const GET: RequestHandler = async ({ url }) => { - const response = { success: false } as APIResponse; - const params = url.searchParams; const endpoint = params.get('endpoint'); - if (endpoint === null) return json(response); + if (endpoint === null) return json({ success: false } as APIResponse); const api_call = await fetch(`http://localhost:8080/${endpoint}`); const data = await api_call.json() as APIResponse; @@ -14,11 +12,9 @@ export const GET: RequestHandler = async ({ url }) => { }; export const POST: RequestHandler = async ({ request }) => { - const response = { success: false } as APIResponse; - const formData = await request.formData(); const endpoint = formData.get('endpoint'); - if (endpoint === null) return json(response); + if (endpoint === null) return json({ success: false } as APIResponse); formData.delete('endpoint'); const api_call = await fetch(`http://localhost:8080/${endpoint}`, {