accounts/ui/panel/lib/api.ts
2025-06-20 08:28:45 +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>
}