Created
July 15, 2022 15:43
-
-
Save raynirola/695eedbe7b3292c88fac0bafaca9fa87 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 sendgrid from '@sendgrid/mail'; | |
sendgrid.setApiKey(process.env.SENDGRID_API_KEY); | |
export default async (req, res) => { | |
try { | |
await sendgrid.send({ | |
to: '[email protected]', | |
from: '[email protected]', | |
subject: 'Serverless Functions', | |
text: 'Hello, world!' | |
}); | |
} catch (error) { | |
return res.status(error.statusCode || 500).json({ error: error.message }); | |
} | |
return res.status(200).json({ error: '' }); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment