()
| 33 | } |
| 34 | useEffect(() => { |
| 35 | const fetchContents = async () => { |
| 36 | const loadedContents: Record<string, string> = {} |
| 37 | for (const [name, path] of Object.entries(source)) { |
| 38 | try { |
| 39 | const response = await fetch(`/stubs/${path}.json`) |
| 40 | const data = await response.json() |
| 41 | loadedContents[name] = data.files[0].content |
| 42 | } catch (error) { |
| 43 | console.error(`Error fetching ${path}:`, error) |
| 44 | } |
| 45 | } |
| 46 | setContents(loadedContents) |
| 47 | } |
| 48 | |
| 49 | fetchContents() |
| 50 | }, [source]) |