Strapi CMS get next or previous entry

774 Views Asked by At

i've created CMS with Strapi /MongoDB and REST/.

Is there any way to get next content. I want to display next content details on specific content page. Or should i customize id field to auto increment field and get content using add one to id field. Thanks

2

There are 2 best solutions below

4
On BEST ANSWER

After few tries, I've decided to make id field to auto increment and sent request by adding or subtracting one from id. There were no other solution. If id is one its first content or if the next contents' response is 404 its the last content. This is how i solved this problem. If you have simpler or better solution let me know. Thanks.

0
On

For previous item you can call get all endpoint with filter with less than actual_ID. And sort it by id and go with size pages 1 and you get first item which is published and exist and is prev. Same for next but with filter with bigger than actual_ID.