Skip to content
Snippets Groups Projects
sendVerificationEmail.ts 661 B
Newer Older
Caner's avatar
Caner committed

export async function sendVerificationEmail(email: string) {

    try {

        const res = await fetch('/api/verifyEmail', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
            },
            body: JSON.stringify({
                email,
            }),
        });

        if (res.ok) {
            alert(`Verification Email was send 🚀,/n Please Verify your Account!`);
        }

        if (res.status === 400) {
            alert(`Something went wrong! Verification Email could not be send 😢`);
        }
    } catch (err) {
        console.log('Something went wrong: ', err);
    }
}