jeffersonRibeiro / react-shopping-cart

🛍️ Simple ecommerce cart application built with Typescript and React

Home Page:https://react-shopping-cart-67954.firebaseapp.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

issue - Server fetch too many times

AndyLIUMel opened this issue · comments

I find whenever the filter/sorting changed, Axios is used to fetch the same remote JSON files, it is not a good practice, as it makes unnecessary server load.
Shall we refactor it so it is only called once?

Hi Andy! you're absolutely right, we shouldn't make unnecessary server load.

I thought about refactoring and do exactly what you told. However, the idea of this demo is to simulate a fetch to a real API in which the sorting/filtering is performed in the server and not in the client as I'm doing here.

In a real API, the sorting/filtering performed in the server would return a different payload each time a sort/filter param would change