Description
Hello. Day 1 with sendGrid. Weekend warrior when it comes to coding.
I have followed the simple instructions and have created a contactUs.js file which looks like this
import sgMail from "@sendgrid/mail";
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const msg = {
to: "[email protected]",
from: "[email protected]",
subject: "Hello world",
text: "Hello plain world!",
html: "
Hello HTML world!
",};
sgMail.send(msg);
(I am using modules as seen above, if I have brought that over correctly)
My .env looks like this
SENDGRID_API_KEY=SG.xW.......
And I am trying to run this in the backend with
$node contactUs.js
I get in return
API key does not start with "SG.".
Followed by ResponseError: Unauthorized ...
What am I am missing in order to get this to go at this point and forward?
The solutions offered online for "API key does not start with "SG."" did not address my issue.
A little help please.