Pagination on get entries for the frontend?

#1

I’ve been checking on many issues and the docs but there seem to be no clear answer.

Is it possible to paginate the results on a get entries of a collection ?

something like:

fetch('/api/collections/collection/posts?page=1&entries=10&token=xxtokenxx')
    .then(collection => collection.json())
    .then(collection => console.log(collection)); // only 10 returned

OR

fetch('/api/collections/collection/posts?take=10&skip=0&token=xxtokenxx')
    .then(collection => collection.json())
    .then(collection => console.log(collection)); // only 10 returned
Basic question re GET vs POST
#2

See DEMO

jsfiddle

1 Like
#3

thanks, it’s very helpful.

It’s pretty weird to do a post request to retreive data though, why is it like that? It’s not really respectful of the rest standards, do you know why it’s like that?

#4

you can also do a GET request, e.g:

fetch('/api/collections/collection/posts?limit=10&skip=10&token=xxtokenxx')

post is nice because of the possible usage of a json body

#5

yes I saw that later on.
Well yes the post lets you use the json body but post is meant to create / add data not retreive it, so it creates confusion.

Also, using something like axios it’s quite simple to parse data to url.

Thanks.