|
|
|
|
|
by AndreasHae
1347 days ago
|
|
I‘m interested in the reasoning why API pagination is hard to add later, or rather what the benefit is of „leaving space“ in the API response while in reality returning all items at once. Wouldn’t have to adapt the way the frontend consumes the API either way, keeping track of the current list state? Or is that what the author meant, that you should always write your list UIs as if they consumed a paginated API? |
|
[{id: 1, …},…]
Then you can't easily add pagination without changing the structure of the response. Whereas if you have something like this:
{results: [{id: 1, …},…]}
then you can add in whatever other properties you need and this change can be made without immediately breaking any existing applications. Of course, it's still true that you'll have to rewrite the frontend to actually implement pagination, but it does do something for backward compatibility. You could probably still have old versions of the application at least display the first page of results without changes.