I'm learning JS, but i can't find how to save a request body after my fetch POST. Using only JS
async function connectUser () {
const log = document.querySelector("#formulaireConnexion")
log.addEventListener("submit", function(event){
event.preventDefault()
const user = {
email: event.target.querySelector("[name=mail]").value,
password: event.target.querySelector("[name=mdp]").value
}
const objectUser = JSON.stringify(user)
fetch("http://localhost:5678/api/users/login", {
method: "POST",
headers: {"Content-Type" : "application/json"},
body: objectUser
}).then(r => r.json())
.then(body => console.log(body))
})
}
connectUser()