feat(web): add api.{get,post,del} typed facade over apiFetch

This commit is contained in:
2026-04-22 16:04:25 -04:00
parent 4d1a7f8b93
commit 37e5539e5a
2 changed files with 33 additions and 1 deletions
+8
View File
@@ -33,3 +33,11 @@ export async function apiFetch(path: string, init?: RequestInit): Promise<unknow
}
return body;
}
export const api = {
get: <T>(path: string): Promise<T> => apiFetch(path) as Promise<T>,
post: <T>(path: string, body: unknown): Promise<T> =>
apiFetch(path, { method: 'POST', body: JSON.stringify(body) }) as Promise<T>,
del: (path: string): Promise<null> =>
apiFetch(path, { method: 'DELETE' }) as Promise<null>
};