airmicrodrip / ui /src /lib /api.ts
josephrw's picture
Upload folder using huggingface_hub
e9d4f6a verified
Raw
History Blame Contribute Delete
321 Bytes
const API_BASE = process.env.NEXT_PUBLIC_API_BASE_URL || '';
export async function fetchApi(path: string) {
const res = await fetch(`${API_BASE}${path}`);
if (!res.ok) {
const text = await res.text().catch(() => 'Unknown error');
throw new Error(`${path}: ${res.status} ${text}`);
}
return res.json();
}