V
V
Viktor Arkhipov2018-09-01 12:02:18
Vue.js
Viktor Arkhipov, 2018-09-01 12:02:18

How to organize the VUE SSR API?

I can't figure out how best to do it. We have pages (components) that have asyncData, on the server side we wait for requests from all components and after that we give the render to the client. If the page had only a list of products, this would not be a problem, but we have different menus / widgets and so on, which also requires a separate request and it turns out that 10 requests to the api will be sent for each page request? Or I do not understand something and everything is wrong, please explain!
I only have this idea:
- each page is a component that forms an array of the components that are in it and makes one request to the api in which all the components used on the page are transferred, and the api forms a response for all these components at once into one and sends it to the application that sends this one response into a state and immediately fills all the necessary states with data without a bunch of separate requests

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mShpakov, 2018-09-01
@mShpakov

Look towards graphql
It hurts at first glance, but when you figure it out, you won't be able to refuse

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question