mirror of
https://git.srhtnin.garden/sarah/srhtnin.github.io.git
synced 2026-10-14 10:48:12 +02:00
Added catalogue version to make webpages not need to repeatedly fetch
info from API.
This commit is contained in:
1 parent
dde47ff5a6
commit
ce6dced3ad
6 files changed
+374
-85
No files matched your search
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user