MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / fetchJSON

Function fetchJSON

web/rusense/app/lib.js:38–50  ·  view source on GitHub ↗
(url, opts = {})

Source from the content-addressed store, hash-verified

36
37/** Fetch JSON with a short timeout; returns null on any failure. */
38export async function fetchJSON(url, opts = {}) {
39 const ctrl = new AbortController();
40 const t = setTimeout(() => ctrl.abort(), opts.timeout ?? 6000);
41 try {
42 const res = await fetch(url, { signal: ctrl.signal, ...opts });
43 if (!res.ok) return null;
44 return await res.json();
45 } catch {
46 return null;
47 } finally {
48 clearTimeout(t);
49 }
50}
51
52export const fmt = {
53 pct: (v, d = 0) => (v == null || isNaN(v) ? '—' : `${(v * (v <= 1 ? 100 : 1)).toFixed(d)}%`),

Callers 15

mountFunction · 0.85
refreshFunction · 0.85
captureLogsFunction · 0.85
mountFunction · 0.85
refreshHealthFunction · 0.85
refreshSightingsFunction · 0.85
refreshVitalsFunction · 0.85
refreshTrendsFunction · 0.85
refreshPresenceFunction · 0.85
loadModelsFunction · 0.85
loadRecordingsFunction · 0.85
loadAdaptiveFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected