Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] ResponseError#response#body has incorrect type #1222

Open
bogdan opened this issue Nov 24, 2020 · 2 comments
Open

[bug] ResponseError#response#body has incorrect type #1222

bogdan opened this issue Nov 24, 2020 · 2 comments
Labels
status: help wanted requesting help from the community type: twilio enhancement feature request on Twilio's roadmap

Comments

@bogdan
Copy link

bogdan commented Nov 24, 2020

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
@thinkingserious
Copy link
Contributor

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

@thinkingserious thinkingserious added status: help wanted requesting help from the community type: twilio enhancement feature request on Twilio's roadmap labels Jan 19, 2021
@bogdan
Copy link
Author

bogdan commented Jan 25, 2021

Well, there is a feature component into that in the "Ideally" section, but there is also a bug that type definition is incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted requesting help from the community type: twilio enhancement feature request on Twilio's roadmap
Projects
None yet
Development

No branches or pull requests

2 participants