import { postData } from "./client.js";

const loginForm = document.getElementById("loginForm");

if (loginForm) loginForm.onsubmit = async e => {
    e.preventDefault();
    let resultObject = await postData("/login", {
        username: document.getElementById("logUser").value,
        password: document.getElementById("logPass").value
    });
    alert(resultObject.message);
    if (resultObject.success) {
        window.location.href = "home.html"
        localStorage.setItem("token", resultObject.token);
    }
};
