I have an API built in lumen and I plan to consume the API json response in the frontend using a single page framework like Angular.
The problem is the response from some routes contain huge amount of data which is aprox 50000 rows as of now. I intend to send the data to the frontend in small portion depending on how much the user is using.
for example on a social site you get small chunks of posts loaded at a time and as you scroll down more post are loaded until you eventual close the application
I would like my API to do something similar. Alternatives that I have considered are
What options do I have for achieving this and also is there a workaround on the options I mentioned above?
THANK YOU
So, since the Paginate method does exactly what you need, you will need to use it. Implement an API function that will receive a starting point and an offset on the server-side.
On the client-side you do not have to display paging controls. You can instead implement a scroll
event and detect if the scrolling reached the bottom. If so, then trigger a function
(still in JS on the client-side), that will ask for the next packet of data. For this purpose, you will always need to know/find out how many records were already loaded and send that number as the starting point and your offset to the API function
we have discussed above.