Added catalogue version to make webpages not need to repeatedly fetch

info from API.
This commit is contained in:
sarah committed 2026-08-31 20:01:56 +02:00
1 parent dde47ff5a6
commit ce6dced3ad
6 files changed
+374 -85

No files matched your search

+5 -29
View File
@@ -1,29 +1,7 @@
let Plants = {};
let PlantsLoadPromise = null;
async function LoadPlants() {
if (PlantsLoadPromise !== null) {
return PlantsLoadPromise;
}
PlantsLoadPromise =
LoadPlantsFromApi();
try {
return await PlantsLoadPromise;
} catch (Error) {
PlantsLoadPromise = null;
throw Error;
}
}
async function LoadPlantsFromApi() {
async function FetchPlantsFromApi() {
const Response =
await fetch(
ApiUrl + "/Plants.php",
@@ -33,7 +11,9 @@ async function LoadPlantsFromApi() {
headers: {
"Accept":
"application/json"
}
},
cache: "no-store"
}
);
@@ -66,9 +46,5 @@ async function LoadPlantsFromApi() {
}
Plants =
Result.Plants;
return Plants;
return Result.Plants;
}