(url, init)
| 80 | } |
| 81 | |
| 82 | export async function fetchJSON(url, init) { |
| 83 | const res = await authedFetch(url, init); |
| 84 | if (!res.ok) { |
| 85 | let detail = `${res.status} ${res.statusText}`; |
| 86 | let body; |
| 87 | try { |
| 88 | body = await res.json(); |
| 89 | if (body && body.detail) detail = String(body.detail); |
| 90 | } catch { |
| 91 | /* non-JSON error body */ |
| 92 | } |
| 93 | const error = new Error(detail); |
| 94 | if (body !== undefined) error.body = body; |
| 95 | throw error; |
| 96 | } |
| 97 | return res.json(); |
| 98 | } |
| 99 | |
| 100 | function relativeTime(deltaSeconds) { |
| 101 | if (Number.isNaN(deltaSeconds)) return "unknown"; |
no test coverage detected