sendgrid-nodejs
sendgrid-nodejs copied to clipboard
Confusing typing
The API for Node JS is confusing and not aligned with the API:
- there's
MailData.text&htmlbut there's alsoMailData.contentwhich is not optional when usingMailData. The two first are not in the API doc butcontentis https://sendgrid.com/docs/api-reference/ - Readme mentions internal classe
Mailthat seems like an option to use but then the typing is not aligned with anything in the documentation. Typescript says you can't callsendwithMailorMailJSON.
The current version forces me to set:
content: [
{ type: 'text/plain', value: '' },
{ type: 'text/html', value: '' },
],
So it's valid Typescript even though we use template ids and values.
Hello @assertnotnull,
Great catch! When using dynamic transactional templates, we don't need to set the content values. I believe the change will need to be implemented here.
This issue has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog.
With best regards,
Elmer
This was confusing to me as well. Seems to still be in there? I'm getting an error if I don't pass in a content field