Search
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user