Skip to content

Commit

Permalink
fixed email
Browse files Browse the repository at this point in the history
  • Loading branch information
korih committed Nov 21, 2024
1 parent 1e778fc commit d11b44a
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/components/contact/mailForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,27 @@ function MailForm() {

const handleSubmit = async (e) => {
e.preventDefault()
if (!firstName || !lastName || !email || !message) {
alert("Please fill out missing info")
return;
}

try {

const response = await fetch("https://twilight-wildflower-fcec.ubcagrobot.workers.dev/", {
await fetch("https://twilight-wildflower-fcec.ubcagrobot.workers.dev/", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: {
body: JSON.stringify({
"firstName": firstName,
"lastName": lastName,
"phoneNumber": phone,
"email": email,
"body": message
}
})
})

if (!response.ok) {
throw Error()
} else {
setFirstName('')
setLastName('')
setPhone('')
setMessage('')
}
} catch (error) {
alert('Error sending message 🙀, sending an email is a good alternative')
}
window.location.reload();
}

return (
Expand Down

0 comments on commit d11b44a

Please sign in to comment.