From 52e30c1e99ab75138cf03a9267d80d860c9c1c3b Mon Sep 17 00:00:00 2001 From: bruno Date: Mon, 5 Feb 2024 23:07:09 +0100 Subject: [PATCH] wait for fetch to finish --- assets/script.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/assets/script.js b/assets/script.js index ebb36b1..79bdb60 100644 --- a/assets/script.js +++ b/assets/script.js @@ -125,10 +125,12 @@ function navigateTo(site, page){ data.append("action", "getPage"); data.append("site", site); data.append("page", page); - doPageAction(data); - localStorage.setItem("currentSite", site); - localStorage.setItem("currentPage", page); - onPageLoad(); + doPageAction(data).then((value) => { + localStorage.setItem("currentSite", site); + localStorage.setItem("currentPage", page); + onPageLoad(); + // Expected output: "Success!" + }); } function softReload(){ @@ -179,18 +181,13 @@ document.addEventListener('DOMContentLoaded', initAjax); function onPageLoad(){ let currentSite = localStorage.getItem("currentSite"); let currentPage = localStorage.getItem("currentPage"); - console.log("We arrived on: " + currentSite + ":" + currentPage + "."); if(currentSite === "home" && currentPage === "settings"){ if(document.getElementById("user-settings")){ getUserInfo(); - console.log("Running user info"); } - } - if(currentSite === "home" && currentPage === "settings"){ if(document.getElementById("admin-settings")){ listActivationCodes(); listUsers(); - console.log("Running admin info"); } } }