(path: string, signal?: AbortSignal)
| 75 | } |
| 76 | |
| 77 | export async function get<T>(path: string, signal?: AbortSignal): Promise<T> { |
| 78 | const resp = await fetch(`${_baseUrl}${path}`, { |
| 79 | headers: getAuthHeaders(), |
| 80 | signal, |
| 81 | }) |
| 82 | handle401(resp) |
| 83 | if (!resp.ok) { |
| 84 | const text = await resp.text().catch(() => '') |
| 85 | throw new Error(`HTTP ${resp.status}: ${text}`) |
| 86 | } |
| 87 | return resp.json() as Promise<T> |
| 88 | } |
| 89 | |
| 90 | export async function post<T>(path: string, body?: unknown, signal?: AbortSignal): Promise<T> { |
| 91 | const hasBody = body !== undefined |
no test coverage detected