( path: string, init?: RequestInit, )
| 9 | * Typed fetch wrapper for the Agentara backend API. |
| 10 | */ |
| 11 | export async function apiFetch<T>( |
| 12 | path: string, |
| 13 | init?: RequestInit, |
| 14 | ): Promise<T> { |
| 15 | const res = await fetch(`${BASE_URL}${path}`, { |
| 16 | ...init, |
| 17 | headers: { |
| 18 | "Content-Type": "application/json", |
| 19 | ...init?.headers, |
| 20 | }, |
| 21 | }); |
| 22 | if (!res.ok) { |
| 23 | throw new Error(`API error ${res.status}: ${res.statusText}`); |
| 24 | } |
| 25 | return res.json() as Promise<T>; |
| 26 | } |
no outgoing calls
no test coverage detected