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}`, {