Skip to content
Discussion options

You must be logged in to vote

Payload doesn't support a skip param in the local API, so you'll need to work around it. The cleanest approach is to query all the data you need in one call, then split it in memory. For example:

const allNews = await payload.find({
 collection: 'news',
 limit: 25,
 sort: '-publishedAt',
});

const featured = allNews.slice(0, 5);
const otherRecent = allNews.slice(5, 25);

This avoids multiple DB hits and keeps pagination logic in your code. If you need more control or want to avoid loading everything at once, you could use the REST API directly with a custom skip query param, but that means bypassing the local API. Adding a skip param to the local API has been requested before, but it's no…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@MurzNN
Comment options

Comment options

You must be logged in to vote
2 replies
@MurzNN
Comment options

@itxashancode
Comment options

Answer selected by MurzNN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants