Answer the question
In order to leave comments, you need to log in
How to sequentially (asynchronously) load components in VUE?
Hello.
I have an "orders-list" component that uses an "order" component inside a loop.
The logic is as follows:
the "orders-list" component is loaded on the page and when it is created, a quick request to the backend results in a list of orders (order numbers), for example, 150 orders come immediately (we request an order for the last 10 days and the backend returns 150 order numbers very quickly) , I show 150 placeholders and a loader in the "orders-list" component (which indicate that information about the order will appear here now)
code like this
<order
v-on:successOrderLoad="onSuccessOrderLoad"
v-for="order in orders"
:key="order"
v-bind:order-num="order">
</order>
Answer the question
In order to leave comments, you need to log in
Perhaps the idea is wrong, but this option is what first came to mind.
async function getData(count) {
for (let i = 0; i < count; i++) {
let data = await fetch('request to backend');
if (data.ok) {} // push it to some store
}
}
Isn't it easier to just ask for 20 full orders at once? And then draw 20 placeholders using scroll/pagination and request 20 new orders from the server?
150 requests - well, that's it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question