6 lines
188 B
TypeScript
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>
|
|
}
|