sendgrid-nodejs
sendgrid-nodejs copied to clipboard
[bug] ResponseError#response#body has incorrect type
Issue Summary
ResponseError#response#body property has a type string assuming it is unparsed json string, but it is parsed json
Code Snippet
import sendgrid from '@sendgrid/mail';
import config from '../config';
sendgrid.setApiKey(config.SENDGRID_API_KEY)
sendgrid.send({
to: '[email protected]',
from: '[email protected]',
subject: 'Test Subject',
text: 'body',
attachments: [{
type: 'text',
content: 'hello',
filename: 'example.txt'
}]
}).catch((error) => {
console.log(typeof error.response.body)
})
Exception/Log
object
Ideally, I would want body to be extensively typed like {body: {errors: {message: string, field: string, help?:string}[]}
Technical details:
- sendgrid-nodejs version: 7.4.0
- node version: 12.18.1
Hello @bogdan,
Thanks for taking the time to report this!
I'm re-classifying this to a feature request since the current behavior is not broken, but it could be optimized.
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
Well, there is a feature component into that in the "Ideally" section, but there is also a bug that type definition is incorrect.