mirror of
https://github.com/Queer-Lexikon/regenbogenkarte
synced 2024-11-10 06:34:21 +00:00
28cb5f0bf0
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>
18 lines
493 B
TypeScript
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;
|
|
};
|