writing the stub js to authenticate against the back end

This commit is contained in:
2024-08-12 21:44:49 +02:00
parent 846282db74
commit aab0ef380a
2 changed files with 42 additions and 3 deletions

33
static/js/login.js Normal file
View File

@ -0,0 +1,33 @@
export function val(api) {
let form = document.getElementById("login_form");
if (form.checkValidity() === false) {
this.event.preventDefault();
this.event.stopPropagation();
form.classList.add("was-validated");
return;
}
form.classList.add("was-validated");
let payload = {
email: document.getElementById("email").value,
password: document.getElementById("password").value,
};
const requestOptions = {
method: 'post',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify(payload),
};
fetch(api + "/api/authenticate", requestOptions)
.then(response => response.json())
.then(response => {
console.log(response)
});
}