sendgrid/sendgrid-nodejs

'content' is declared here.

cavedweller opened this issue · 2 comments

I am very new to using this package so apologies in advance if I have missed something.

I am trying to use a template id in the message data but i get the error:
Argument of type '{ to: string; from: string; template_id: string; }' is not assignable to parameter of type 'MailDataRequired | MailDataRequired[]'. Type '{ to: string; from: string; template_id: string; }' is not assignable to type 'MailData & { content: MailContent[] & { 0: MailContent; }; }'. Property 'content' is missing in type '{ to: string; from: string; template_id: string; }' but required in type '{ content: MailContent[] & { 0: MailContent; }; }'.ts(2345) mail.d.ts(161, 70): 'content' is declared here.

The format that I am using is as follows:

 const msg = {
    to: "xxxxx@xxx.com", 
    from: "yyyy@yyy.com", 
    template_id: "d-01cxxxxxxxxxxxxxxxxxxxxx1a",
  };
 await sgMail.send(msg);

I am using the current versions of 7.4.6

I just cannot seem to find out what I am doing wrong.

Should be templateId and not template_id

Ah so silly, thank you so much :)