bunker/public/login.js
SimonFJ20 a03ad035fb
All checks were successful
Validate / Validate (push) Successful in 9s
init
2024-09-20 04:42:15 +02:00

16 lines
470 B
JavaScript

document.querySelector("#login").onsubmit = async (event) => {
event.preventDefault();
const form = new FormData(event.target);
const body = JSON.stringify({
username: form.get("username"),
password: form.get("password"),
});
const res = await fetch("/api/login", {
method: "POST",
headers: new Headers({ "Content-Type": "application/json" }),
body,
}).then((res) => res.json());
console.log(res);
};