async function login() {
    // this.preventDefault();
    // get login details
    let name = document.getElementById("name").value;
    let password = document.getElementById("password").value;
    // request login
    let response = await fetch("/login", {
        method: "POST",
        headers: {
            "Content-Type": "application/json",
        },
        body: JSON.stringify({
            name: name,
            password: password
        })
    });
    // if failed red button
    // else switch screen
    if (response.status != 200) {
        document.getElementById("loginSubmit").classList.add("error");
    } else {
        // switch screen
        document.getElementById("login").setAttribute("style", "display: none;");
        document.getElementById("mainPage").setAttribute("style", "");
    }
}