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] Pagination not working (tweets.fetchNext() always retrieving same tweets). #404

Open epsilongithub opened 1 year ago

epsilongithub commented 1 year ago

Describe the bug I'm trying to get all the tweets since a date. I first use userTimeline() and recieve 100 tweets. Then, I try to fetch the next results, but function always returns the same results.

To Reproduce Please indicate all steps that lead to this bug:

  1. Request client setup (login method, OAuth2 scopes if applicable...) image
  2. I use the endpoint of timeline to get the tweets image
  3. After receiving the api response, I try to iterate but I always get the same tweets. image

Expected behavior What I expect is to receive all the tweets within the dates with the iteration.

Version

alkihis commented 1 year ago

Hi, Did you find a way to overcome this issue? I cannot reproduce on my side, can you check what is the complete result on the first call (JSON.stringify(tweets.data))?

epsilongithub commented 1 year ago

Hi, Did you find a way to overcome this issue? I cannot reproduce on my side, can you check what is the complete result on the first call (JSON.stringify(tweets.data))?

The solution was to make the api with my own hand hahahaha If I remember correctly, the problem was that it was not able to send the pagination with the request or else it was because the library itself was not able to pass you the new twetts.

alkihis commented 1 year ago

Ok, no problem :D Can I close the issue, so, if you moved to something else and I cannot repro?

anianroid commented 1 year ago

I found a solution. Just pass count like this await client.v1.searchUsers(searchQuery, { page: count }) and keep incrementing count on load more or something like that.

uluhonolulu commented 1 year ago

@alkihis I have the same issue. It looks like the paginator doesn't update the page number in fetchNext. getNextQueryParams always returns page: 2 because this._queryParams.page is always 1.

Same with fetchLast.

The workaround it to use next() (which is awkward) or manually update the page number:

usersPaginator._queryParams = usersPaginator.getNextQueryParams();