Player search
This commit is contained in:
36
public/info.js
Normal file
36
public/info.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import { postData, verifyLogin } from "./client.js";
|
||||
|
||||
verifyLogin();
|
||||
const token = window.localStorage.getItem("token");
|
||||
|
||||
const infoForm = document.getElementById("infoForm");
|
||||
|
||||
async function fetchPersonalInformation() {
|
||||
const userData = await postData("https://134.209.36.64:3000/getInfo", {}, token);
|
||||
|
||||
console.log(userData);
|
||||
|
||||
document.getElementById("usernameField").textContent = userData.Username;
|
||||
document.getElementById("firstNameField").value = userData.FirstName;
|
||||
document.getElementById("lastNameField").value = userData.LastName;
|
||||
document.getElementById("dobField").value = userData.DOB.split("T")[0];
|
||||
|
||||
return userData
|
||||
}
|
||||
|
||||
const userData = fetchPersonalInformation();
|
||||
|
||||
async function updatePersonalInformation(e) {
|
||||
console.log(verifyLogin());
|
||||
e.preventDefault();
|
||||
const userData = {
|
||||
firstName: document.getElementById("firstNameField").value,
|
||||
lastName: document.getElementById("lastNameField").value,
|
||||
dob: document.getElementById("dobField").value
|
||||
}
|
||||
console.log(userData.dob);
|
||||
const resultObject = await postData("https://134.209.36.64:3000/setInfo", userData, token);
|
||||
alert(resultObject.message);
|
||||
}
|
||||
|
||||
infoForm.onsubmit = updatePersonalInformation;
|
||||
Reference in New Issue
Block a user