Skip to content
Advertisement

Vuex Store Object Child returns undefined, parent returns properly. Why?

I’ve seen some similar questions but they don’t seem to match my situation.

When I log this.$store.state.account I get the expected result

JavaScript

However, when I console.log(this.$store.state.account.user) the user object disappears! All of the nested properties inside user return undefined though they log perfectly fine above

console.log(this.$store.state.account.user)

JavaScript

This is the method inside my component calling the object

JavaScript

this is the action inside my accounts module that binds the user to firebase

JavaScript

Not sure what further information would be relevant aside that this.$store.state.account.user is binded via Vuexfire to a database reference. The store is injected into the root component

Advertisement

Answer

Your data comes in after the console.log. The console updates object/array logs with current values when you click, but can’t do that with primitives. See this answer for more detail.

It should be enough to await the firebaseAction:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement