node-twitter-api-v2
node-twitter-api-v2 copied to clipboard
[bug] Pagination not working (tweets.fetchNext() always retrieving same tweets).
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:
- Request client setup (login method, OAuth2 scopes if applicable...)
- I use the endpoint of timeline to get the tweets
- After receiving the api response, I try to iterate but I always get the same tweets.
Expected behavior What I expect is to receive all the tweets within the dates with the iteration.
Version
- Node.js 16.17.0
- Lib 1.12.9
- OS Linux Debian Server 16.04
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)
)?
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.
Ok, no problem :D Can I close the issue, so, if you moved to something else and I cannot repro?
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.
@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();