typeorm-pagination
typeorm-pagination copied to clipboard
[BUG]: when calling 2 endpoints together (with Promise.all) the page & per_page are set incorrectly
I noticed when calling 2 endpoints with Promise.all
, the pagination parameters for page
& per_page
are not working correctly. It always takes the parameters of the last endpoint in the list.
When I call them one by one or with only one in the Promise.all
, it does work correctly
Been having the same problem with concurrent requests on my Nest JS backend.
Solved it by making the following changes to the code: Changed the paginate method to accept an object with {per_page, page} Change the priority of the parameters to: 1st the object passed to paginate 2nd the query object on the request 3rd the default values.
What was happening in my case is that the 1st request was setting per_page to X, and before the query was executed, the second request came and changed per_page to Y. Using the parameters passed directly to .paginate solved it for me.