(path, options = {})
| 587 | return { 'Content-Type': 'application/json', 'Authorization': `Bearer ${S.admin.token}` }; |
| 588 | } |
| 589 | async function api(path, options = {}){ |
| 590 | const res = await fetch(path, { ...options, headers: { ...(options.headers || {}), ...(options.auth === false ? {} : adminHeaders()) } }); |
| 591 | const data = await res.json().catch(() => ({})); |
| 592 | if(!res.ok || data.ok === false) throw new Error(data.error || res.statusText); |
| 593 | return data; |
| 594 | } |
| 595 | async function ensureAdminChecked(){ |
| 596 | if(S.admin._checking) return; |
| 597 | S.admin._checking = true; |
no test coverage detected