(path)
| 34 | } |
| 35 | |
| 36 | async function apiGet(path) { |
| 37 | const resp = await fetch(withBase(path), { |
| 38 | method: 'GET', |
| 39 | credentials: 'include', |
| 40 | headers: { Accept: 'application/json' } |
| 41 | }); |
| 42 | const body = await safeJson(resp); |
| 43 | if (!resp.ok || !body || body.ok === false) { |
| 44 | throw new Error((body && (body.error || body.message || body.assistant)) || `HTTP ${resp.status}`); |
| 45 | } |
| 46 | return body; |
| 47 | } |
| 48 | |
| 49 | async function apiPost(path, payload) { |
| 50 | const resp = await fetch(withBase(path), { |
no test coverage detected