This commit is contained in:
admin
2026-09-03 22:02:52 +09:00
commit 659725de15
90 changed files with 2840 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
export async function apiRequest<T>(input: string, init?: RequestInit) {
const response = await fetch(input, {
credentials: "same-origin",
headers: {
"Content-Type": "application/json",
...(init?.headers ?? {})
},
...init
});
if (!response.ok) {
const data = await response.json().catch(() => ({ message: "Request failed." }));
throw new Error(data.message ?? "Request failed.");
}
return response.json() as Promise<T>;
}