(res)
| 475 | |
| 476 | // Tiny JSON helper (same behavior as in adminPanel.js) |
| 477 | async function safeJson(res) { |
| 478 | const text = await res.text(); |
| 479 | let body = null; |
| 480 | try { body = text ? JSON.parse(text) : null; } catch (e) { /* ignore */ } |
| 481 | if (!res.ok) { |
| 482 | const msg = |
| 483 | (body && (body.error || body.message)) || |
| 484 | (text && text.trim()) || |
| 485 | `HTTP ${res.status}`; |
| 486 | const err = new Error(msg); |
| 487 | err.status = res.status; |
| 488 | throw err; |
| 489 | } |
| 490 | return body ?? {}; |
| 491 | } |
| 492 | |
| 493 | // Reusable custom confirm using #customConfirmModal from index.html |
| 494 | function portalConfirm(message) { |
no outgoing calls
no test coverage detected