Answer the question
In order to leave comments, you need to log in
What is the best way to get data from several endpoints?
When loading a page via Rest, I receive data from 3 endpoints - user, products, banners - at the moment I make requests independently from each other in different actions. Is it right to do this, or do I need to combine several requests into one, for example, through axios.all ?
Answer the question
In order to leave comments, you need to log in
User data, in a good way, should be requested in the application initialization action, and the loading of goods should be initiated in the cdm of the product page.
If you really want to fix three requests for one, you can create one common controller that will collect data from 3 other controllers and send everything in one response
REST implies a lot of endpoints that will be called independently of each other, so overfetching for applications with a REST backend is the norm. If this becomes a problem in terms of performance / traffic, then you need to think about combining either queries or endpoints, or leave REST altogether, for example, in GraphQL
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question