regenbogenkarte/ts/data.ts
Zora Franke 28cb5f0bf0
Django backend preparation (#147)
This prepares the data fetching for the upcoming Django backend.
It is made in a backwards-compatible way to ensure no breakage
of the existing map.

Co-authored-by: Zora Franke <zora@zorafranke.de>
2024-06-29 14:02:20 +00:00

18 lines
493 B
TypeScript

import data from "../data/orgas.json";
export const loadJSON = async () => {
if (!import.meta.env.VITE_QUEER_LEXIKON_BACKEND_URL) {
console.warn("The backend URL is not defined, using compiled JSON as fallback.");
return data;
}
const resp = await fetch(import.meta.env.VITE_QUEER_LEXIKON_BACKEND_URL);
if (!resp.ok) {
console.warn("Loading the data from the backend failed, using compiled JSON as fallback.");
return data;
}
const json = await resp.json();
return json;
};