This commit is contained in:
phaichayon
2026-04-16 14:06:59 +07:00
parent 1e8d6a9b19
commit 4702150af1
50 changed files with 3815 additions and 3 deletions

14
src/lib/api-client.ts Normal file
View File

@@ -0,0 +1,14 @@
const BASE_URL = '/api';
export async function apiClient<T>(endpoint: string, options?: RequestInit): Promise<T> {
const res = await fetch(`${BASE_URL}${endpoint}`, {
headers: { 'Content-Type': 'application/json' },
...options
});
if (!res.ok) {
throw new Error(`API error: ${res.status} ${res.statusText}`);
}
return res.json() as Promise<T>;
}