Skip to content

Instantly share code, notes, and snippets.

@raynirola
Created July 15, 2022 15:43
Show Gist options
  • Save raynirola/695eedbe7b3292c88fac0bafaca9fa87 to your computer and use it in GitHub Desktop.
Save raynirola/695eedbe7b3292c88fac0bafaca9fa87 to your computer and use it in GitHub Desktop.
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