MCPcopy Create free account
hub / github.com/github/awesome-copilot / fetchData

Function fetchData

website/src/scripts/utils.ts:50–65  ·  view source on GitHub ↗
(
  filename: string
)

Source from the content-addressed store, hash-verified

48 * Fetch JSON data from the data directory
49 */
50export async function fetchData<T = unknown>(
51 filename: string
52): Promise<T | null> {
53 const embeddedData = getEmbeddedPageData<T>(filename);
54 if (embeddedData !== null) return embeddedData;
55
56 try {
57 const basePath = getBasePath();
58 const response = await fetch(`${basePath}data/${filename}`);
59 if (!response.ok) throw new Error(`Failed to fetch ${filename}`);
60 return await response.json();
61 } catch (error) {
62 console.error(`Error fetching ${filename}:`, error);
63 return null;
64 }
65}
66
67let jsZipPromise: Promise<typeof import("./jszip")> | null = null;
68

Callers

nothing calls this directly

Calls 1

getBasePathFunction · 0.85

Tested by

no test coverage detected