MCPcopy Create free account
hub / github.com/error311/FileRise / safeJson

Function safeJson

public/js/adminPortals.js:477–491  ·  view source on GitHub ↗
(res)

Source from the content-addressed store, hash-verified

475
476// Tiny JSON helper (same behavior as in adminPanel.js)
477async 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
494function portalConfirm(message) {

Callers 5

fetchAllPortalsFunction · 0.70
saveAllPortalsFunction · 0.70
loadPortalSourcesFunction · 0.70
fetchPortalSubmissionsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected