Created
July 18, 2023 10:04
-
-
Save ByteCrak07/38cd9429d14a9ec65d55932c5769cdba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { FormData } from '@/components/contact'; | |
export function sendEmail(data: FormData) { | |
const apiEndpoint = '/api/email'; | |
fetch(apiEndpoint, { | |
method: 'POST', | |
body: JSON.stringify(data), | |
}) | |
.then((res) => res.json()) | |
.then((response) => { | |
alert(response.message); | |
}) | |
.catch((err) => { | |
alert(err); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment