I have a frontend built in React and a backend built in Express. I query my API from the frontend, and get back 10 results. This is the query in the backend
SELECT * FROM games LIMIT 10
Say I wan to implement infinite scroll. I’d like to query 10 more results, but not the same as before. What technique could I use, both/either on frontend or backend code?
Could I pass perhaps a number to my api string which gets incremented every time, e.g. 1st 10, then 20, then 30, to show the number of results, but how can I do that in a SQL query?
SELECT * FROM games LIMIT 10 OFFSET 10
Here you will get item 11 to 20. Now you can change the offset value to whatever you want.
Answered By – Gyanendro Kh