(url: string)
| 16 | }; |
| 17 | |
| 18 | const fetchJsonOnce = async (url: string) => { |
| 19 | if (!fetchPromises.get(url)) { |
| 20 | fetchPromises.set(url, fetch(url)); |
| 21 | } |
| 22 | const response = await fetchPromises.get(url); |
| 23 | |
| 24 | if (response && !jsonPromises.get(url)) { |
| 25 | jsonPromises.set(url, response.json()); |
| 26 | } |
| 27 | |
| 28 | return jsonPromises.get(url); |
| 29 | }; |
| 30 | |
| 31 | export { fetchTextOnce, fetchJsonOnce }; |