( filename: string )
| 48 | * Fetch JSON data from the data directory |
| 49 | */ |
| 50 | export 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 | |
| 67 | let jsZipPromise: Promise<typeof import("./jszip")> | null = null; |
| 68 |
nothing calls this directly
no test coverage detected