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

Function safeJson

public/js/adminFolderAccess.js:162–176  ·  view source on GitHub ↗
(res)

Source from the content-addressed store, hash-verified

160}
161
162async 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
178function isAdminUser(u) {
179 if (!u) return false;

Callers 4

getAllFoldersFunction · 0.70
getUserGrantsFunction · 0.70
fetchAllGroupsFunction · 0.70
saveAllGroupsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected