PLhery / node-twitter-api-v2

Strongly typed, full-featured, light, versatile yet powerful Twitter API v1.1 and v2 client for Node.js.
https://www.npmjs.com/package/twitter-api-v2
Apache License 2.0
1.29k stars 176 forks source link

[bug] Undefined "data" field on StreamingV2GetRulesResult #330

Closed NoUJoe closed 2 years ago

NoUJoe commented 2 years ago

The "data" field on StreamingV2GetRulesResult isn't defined as optional, however, if you have no rules set (therefore no rules returned in response) then the data field is undefined. Not sure if the type definition is wrong or if an empty array should be returned when there's no rules.

alkihis commented 2 years ago

Hi, Many endpoints behave like this. I've noticed this after first release of the lib (because Twitter do not document it). Making data property optional is a major breaking change and can be painful in 95% of use-cases, so it's untouched for now.

NoUJoe commented 2 years ago

Appreciate the explanation. I'll just make sure to always check the data property to see if it's undefined