TypeScriptAPI
Typed API fetch helper
A small fetch wrapper with typed JSON responses and clear error handling.
export async function apiFetch<T>(path: string): Promise<T> {
const response = await fetch(path);
if (!response.ok) {
throw new Error(`Request failed: ${response.status}`);
}
return response.json() as Promise<T>;
}fetchapitypescript