D
D
Dmitriy G2020-09-25 17:38:21
Vue.js
Dmitriy G, 2020-09-25 17:38:21

How to do loading step by step in vuex?

Hello everyone, how to make dependent loading in vuex until (for example) the user object is loaded, do not start loading other data that depends on this user object,
I know that it is possible through then ()
But the user is loaded at one entry point in the store and does not I want to write the same request in each route where the user ID is needed

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Borutkin, 2020-09-28
@Atanvar

if this is a one-time action, call all the necessary actions in the root component via Promise.all.
if often - for example, you need to get data from method A and they depend on B
In call action A

try {
await вызывает мотод B
await вызывает метод А
сохраняем данные а в стейт
}

Don't try to overcomplicate where you shouldn't.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question