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!
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.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community