Closed SomveerKr closed 9 months ago
Does this happen after some iterations or on the first iteration while fetching all favoriters?
Okay, I was able to reproduce the issue, working on a fix now.
@SomveerKr The problem that is happening is that the while processing the list of favoriters, one of the favoriter's Twitter account has been suspended/deleted. So it's details are empty and as such, the processing fails.
I'll make sure to prevent such an error crashing the package in a minor patch.
@SomveerKr Please update to v2.2.2
Thanks, for so much speedy fix, I have already fixed this error week ago(while working on client's project), just wanted to tell you that this issue exists so that it get fixed before anyone else uses it.
Here is what I implemented to fix this issue: I changed the code in CursoredData.js to this for (var _i = 0, list_1 = list; _i < list_1.length; _i++) { var item = list_1[_i]; // If the item is a valid raw tweet if (typeof item !== "undefined" && item.typename == 'Tweet' && item.rest_id) { this.list.push(new Tweet_1.Tweet(item)); } // If the item is a valid raw user else if (typeof item !== "undefined" && item.typename == 'User' && item.rest_id && item.id) { this.list.push(new User_1.User(item)); } }
from this for (var _i = 0, list_1 = list; _i < list_1.length; _i++) { var item = list_1[_i]; // If the item is a valid raw tweet if (item.typename == 'Tweet' && item.rest_id) { this.list.push(new Tweet_1.Tweet(item)); } // If the item is a valid raw user else if (item.typename == 'User' && item.rest_id && item.id) { this.list.push(new User_1.User(item)); } }
Thanks for the feedback!
What I did to fix it is this:
// Deserializing the input raw data and storing it in the list for (const item of list) { // If the item is a valid raw tweet if (item && item.__typename == 'Tweet' && item.rest_id) { this.list.push(new Tweet(item as IRawTweet) as T); } // If the item is a valid raw user else if (item && item.__typename == 'User' && item.rest_id && (item as IRawUser).id) { this.list.push(new User(item as IRawUser) as T); } }
If only I weren't lazy regarding edge cases :P
I was getting below errors while trying to get all the favoriters(all users who have liked partcular tweet) of a tweet using rettiwt.tweet.favoriters(tweetId)
TypeError: Cannot read properties of undefined (reading '__typename') at new CursoredData (F:\twitter-api\retwitt\node_modules\rettiwt-api\dist\models\CursoredData.js:45:22) at FetcherService.extractData (F:\twitter-api\retwitt\node_modules\rettiwt-api\dist\services\FetcherService.js:161:16) at TweetService. (F:\twitter-api\retwitt\node_modules\rettiwt-api\dist\services\FetcherService.js:181:37)
at step (F:\twitter-api\retwitt\node_modules\rettiwt-api\dist\services\FetcherService.js:33:23)
at Object.next (F:\twitter-api\retwitt\node_modules\rettiwt-api\dist\services\FetcherService.js:14:53)
at fulfilled (F:\twitter-api\retwitt\node_modules\rettiwt-api\dist\services\FetcherService.js:5:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)