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

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

if (registerForm) registerForm.onsubmit = async e => {
    e.preventDefault();
    let resultObject = await postData("http://134.209.36.64:3000/register", {
        username: registerForm.regUser.value,
        password: registerForm.regPass.value,
        role: registerForm.regRole.value
    });
    alert(resultObject.message);
    if (resultObject.success === true) {
        window.location.href = "login.html";
    }
};
