Hello please help me to send form to email!
Unhandled Rejection (TypeError): Cannot read property 'value' of undefined Error on const handleSubmit
It is source code:
const Form = () => {
const classes = useStyles();
const [status, setStatus] = useState("Submit");
const handleSubmit = async (e) => {
e.preventDefault();
setStatus("Sending...");
const { name, email, message } = e.target.elements;
let details = {
name: name.value,
email: email.value,
message: message.value,
};
let response = await fetch("http://localhost:5000/contact", {
method: "POST",
headers: {
"Content-Type": "application/json;charset=utf-8",
},
body: JSON.stringify(details),
});
setStatus("Submit");
let result = await response.json();
alert(result.status);
};
e.target.elements.name
is null; inspecte.target.elements
. – Stephen Collins