I have a web service built with Spring, my view is built with React and I use Redux for state management.
Let's say my API has an endpoint /api/products
and I've implemenented search functionality, which pulls all the products from the enpoint, stores them in Redux store and displays them. Now I want to implement sorting functionality and I have two ideas for achieving it:
Modify my api endpoint /api/products
to take parameters. For example /api/products?sortBy=price
(less logic in UI, more network requests)
Use the products that I have stored in the store. (less network requests, more logic in UI)
Which one of these, if any, would be considered as the best practice?
It would depend on
I hope this will give you the general idea on how to decide. Maybe able to discuss more if you have details of your specific situation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With