The trick is the onSubmit={handleSubmit} in your form with:
function handleSubmit(e) {
// Prevent the browser from reloading the page
e.preventDefault();
// Read the form data
const form = e.target;
const formData = new FormData(form);
const formJson = Object.fromEntries(formData.entries());
console.log(formJson);
}