Add Webapp

This commit is contained in:
clinton committed 2026-04-03 12:35:13 +02:00
commit ed924ef2ac
76 files changed
+17054

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
"use server";
import { cookies } from "next/headers";
const _URL = `http://localhost:8081/api`;
export async function CallApi<T>(
endPoint: string,
method: "GET" | "POST",
body?: any,
){
const session = (await cookies()).get("ccsession")?.value ?? ("" as string);
const res = await fetch(`${_URL}${endPoint}`, {
method,
headers: {
"content-type": "application/json",
Authorization: `Bearer ${session}`,
},
body: JSON.stringify(body),
}).catch((e) => console.error(e));
if (!((res as Response).status === 200))
throw Error(JSON.stringify(await (res as Response).json()));
return await (res as Response).json();
}