sendgrid-nodejs
sendgrid-nodejs copied to clipboard
Enable sandbox mode for all requests
I have the following file that handles my sendgrid set up.
import sgMail from '@sendgrid/mail';
const sendGridApiKey = process.env.SENDGRID_API_KEY;
if (!sendGridApiKey) {
throw new Error('The sendgrid api key has not been set in the environment variables');
}
sgMail.setApiKey(sendGridApiKey);
export { sgMail };
After setting my api key I need to be able to do something like this to enable sandbox mode on all requests
sgMail.enableSandbox(process.env.NODE_ENV !== 'production')
The absolute best solution would be not having to add a line of code like that at all but be able to generate an api key specifically for sandbox mode (similar to how Stripe has test keys). I really don't want to use my live production key in staging and development environments. Thanks!