Home > Net >  React, e-commerce data, endpoints
React, e-commerce data, endpoints

Time:07-07

I'm working to a e-commerce website (for practice) and I need an opinion.

If I have different pages like: all products, PC Products, For Home Products. I need to have different endpoint for every page, for e.g if I'm on PC Products I make a call to '/pc-products' or should I create one endpoint with all products, make a call on every pages, get all the products and find a way to filter them by categories ?

CodePudding user response:

I believe it strongly depends on the amount of products you need to fetch and overall app architecture.

If the list is short - one endpoint should be enough. This approach will also improve UX while navigating through different categories and filtering.

On the other hand, if list is large (or may become in future) one endpoint will hurt app performance badly and will be more expensive in terms of resources used.

To sum up: one endpoint for MVP / just a few products and multiple endpoints for larger amounts of data / production grade apps.

CodePudding user response:

Creating a big bundled endpoint won't be desired for production level application. Instead of doing this, you should create endpoints for each page/category. With this approach, you are not going to fetch unnecessary products which makes your site faster.

  • Related