This commit is contained in:
RochesterX
2025-11-18 21:16:35 -05:00
parent 908129e38f
commit 9e88712e9f
21 changed files with 235 additions and 120 deletions

View File

@@ -1,8 +1,6 @@
export async function postData(url, data, token = null) {
const elements = url.split("/");
const end = elements[elements.length - 1];
const res = await fetch(end, token == null ? {
console.log("fetching here: " + url);
const res = await fetch(url, token == null ? {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(data)
@@ -19,7 +17,7 @@ export async function postData(url, data, token = null) {
if (resultObject.logout === true) {
alert("Session expired; please log in again.");
window.location.href = "login.html";
window.location.href = "/login";
return resultObject;
}
@@ -32,13 +30,13 @@ export async function verifyLogin() {
token = JSON.stringify(localStorage.getItem("token"));
} catch (error) {
alert("You are not logged in.");
window.location.href = "login.html";
window.location.href = "login";
console.log("Error encountered: " + error);
return false;
}
if (!token) {
alert("You are not logged in.");
window.location.href = "login.html";
window.location.href = "/login";
console.log("Token was null");
return false;
}