MCPcopy Create free account
hub / github.com/ShivaBhattacharjee/KeyZen / fetchJSON

Function fetchJSON

data/javascript/09_error_handling.js:1–12  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

1async function fetchJSON(url) {
2 try {
3 const res = await fetch(url);
4 if (!res.ok) {
5 throw new Error(`HTTP ${res.status}`);
6 }
7 return await res.json();
8 } catch (err) {
9 console.error("fetch failed:", err.message);
10 return null;
11 }
12}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected