$(document).ready(() => {
    $("#loginForm").submit(() => {
        $.ajax({
            type: "POST",
            url: "/api/login",
            data: JSON.stringify({
                username: $("#username").val(),
                password: $("#password").val(),
            }),
            contentType: 'application/json',
            success: function() {
                window.location.href = "/index";
            },
            error: function(xhr) {
                alert (xhr.responseText);
            }
        })
    })
});