All files / src/utilities checkEmailExistance.js

100% Statements 9/9
100% Branches 0/0
100% Functions 3/3
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14  3x 3x 3x 3x 2x 2x   2x   1x 1x    
export default async function checkEmailExistance(email) {
    try {
        const query = `?email=${email}&api_key=${process.env.VERIFY_EMAIL_API_KEY}`;
        const url = `https://api.hunter.io/v2/email-verifier${query}`;
        const response = await fetch(url)
            .then(res => res.json())
            .then(response => response?.data?.status === "valid")
 
        return response
    } catch (error) {
        console.log(error)
        return null;
    }
}