Support the ongoing development of →
Requests Database
Last updated 1 year ago.

Here is my suggestion: your REST API should be something like: /api/posts?start={start_id}&size={size_of_list}

Set a default value for start (0) and size (50) if nothing is provided as part of the REST API.

IF start == 0 query_posts->where('id', '>', start)->orderBy('id', 'desc')->take(size) else query_posts->where('id', '<', start)->orderBy('id', 'desc')->take(size)

when you iterate through the results, set the last id as the new start id.

good luck!

Last updated 1 year ago.

Well the way I create feeds in mobile apps is have a api request that get's all the latest feed posts. Then handle the pagination in the mobile language. I thought about what your doing saving the spot and calling another request when the user want's to load more posts but it seemed like that's a very inefficient way and could add up in calls to the api.

My answer only works if you want to get 50 posts at first then another 50 when the user scrolls down? I might not be understanding your question though?

Good luck on your project.

Last updated 1 year ago.

Sign in to participate in this thread!


Your banner here too?

KarlPi karlpi Joined 20 Mar 2014


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2023 - All rights reserved.