form.addEventListener("submit", async (e) => {
e.preventDefault();
const formData = new FormData(form);
const name = formData.get("name");
form.reset();
let user = {
name: name,
};
let res = await fetch("http://127.0.0.1:5500/data.json", {
method: "POST",
headers: {
"Content-Type": "application/json; charset=UTF-8",
},
body: JSON.stringify(user),
});
let result = res.json();
alert(result);
});