accounts/ui/nextjs/lib/api.ts
2025-06-18 10:51:38 +08:00

6 lines
188 B
TypeScript

export async function fetchJSON<T>(url: string): Promise<T> {
const res = await fetch(url)
if (!res.ok) throw new Error(`API error: ${res.status}`)
return res.json() as Promise<T>
}