(res)
| 160 | } |
| 161 | |
| 162 | async function safeJson(res) { |
| 163 | const text = await res.text(); |
| 164 | let body = null; |
| 165 | try { body = text ? JSON.parse(text) : null; } catch (e) { /* ignore */ } |
| 166 | if (!res.ok) { |
| 167 | const msg = |
| 168 | (body && (body.error || body.message)) || |
| 169 | (text && text.trim()) || |
| 170 | `HTTP ${res.status}`; |
| 171 | const err = new Error(msg); |
| 172 | err.status = res.status; |
| 173 | throw err; |
| 174 | } |
| 175 | return body ?? {}; |
| 176 | } |
| 177 | |
| 178 | function isAdminUser(u) { |
| 179 | if (!u) return false; |
no outgoing calls
no test coverage detected