I am trying to set up SendGrid add-on in my Heroku NodeJS app.
I created the API Key and set it as an environment variable.
The whole API key looks something like: SG.actualValue.bbb_cccccc
The first setup I did I set the whole key as as my SENDGRID_API_KEY and I got this error:
API key does not start with SG.
So, I realized the mistake and unset the environment variable and set it again only to the actualValue part of the whole key.
However, I still get the same error. I tried doing the same thing again or restarting the terminal(actually, whole laptop).
This is the test code I am trying to run from the SendGrid setup page:
const sgMail = require('@sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID_API_KEY)
const msg = {
to: '[email protected]',
from: '[email protected]',
subject: 'Sending with Twilio SendGrid is Fun',
text: 'and easy to do anywhere, even with Node.js',
html: '<strong>and easy to do anywhere, even with Node.js</strong>',
};
sgMail.send(msg);
I tried creating a new key and setting it, but I get the same error. I tried setting it to the whole key, but without .SG or just the bbb_ccccc part. Thank you in advance.