36 lines
1.0 KiB
HTML
36 lines
1.0 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<title>Register</title>
|
|
</head>
|
|
<body>
|
|
<h1>Register</h1>
|
|
<form id="registerForm">
|
|
<input type="text" id="username" placeholder="Username" /><br />
|
|
<input type="password" id="password" placeholder="Password" /><br />
|
|
<button type="submit">Register</button>
|
|
</form>
|
|
|
|
<p id="msg"></p>
|
|
|
|
<script>
|
|
document
|
|
.getElementById("registerForm")
|
|
.addEventListener("submit", async (e) => {
|
|
e.preventDefault();
|
|
const res = await fetch("/api/user/register", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({
|
|
username: document.getElementById("username").value,
|
|
password: document.getElementById("password").value,
|
|
}),
|
|
});
|
|
document.getElementById("msg").textContent = res.ok
|
|
? "Registered! Cookie set."
|
|
: "Error registering.";
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|