Skip to content

Instantly share code, notes, and snippets.

@ByteCrak07
Created July 18, 2023 10:04
Show Gist options
  • Save ByteCrak07/38cd9429d14a9ec65d55932c5769cdba to your computer and use it in GitHub Desktop.
Save ByteCrak07/38cd9429d14a9ec65d55932c5769cdba to your computer and use it in GitHub Desktop.
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