Answer the question
In order to leave comments, you need to log in
How to wait for data in store and use it in beforeMount?
Now I have a method in beforeMount that uses data from the store
. When the component is loaded for the first time, this method in beforeMount fires, but the data has not yet arrived in the store.
I'm trying to watch store changes via vm.$watch(spyData, myMethod)
But that doesn't solve the problem
Answer the question
In order to leave comments, you need to log in
1. made spyData a computed property
2. in beforeMount() made a check:
spyData.length > 0 ? myMethod() : null
3. And accordingly, beforeMount() already had:
vm.$watch(spyData, myMethod)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question