Skip to content

Getting only the first results of a paginated endpoint #321

Answered by alkihis
alkihis asked this question in Q&A
Discussion options

You must be logged in to vote

You need to understand how the tweet paginator works.

// This object is a paginator that holds, at first, the initial 1st page of result
jsTweets

// This is how you access in a Array structure the currently loaded tweets
jsTweets.tweets

// This is how you access the "includes" property linked to all loaded tweets yet
jsTweets.includes

// Those two loops are exactly the same and iterates over the LOADED tweets
for (const tweet of jsTweets) {

}
for (const tweet of jsTweets.tweets) {

}

// This is how you load the "next page"
await jsTweets.fetchNext()

// Now, it will iterate over first and second page
for (const tweet of jsTweets) {

}

// Hint: if you want to have first and second pa…

Replies: 1 comment

Comment options

alkihis
Jul 6, 2022
Collaborator Author

You must be logged in to vote
0 replies
Answer selected by alkihis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant