Skip to content

User doc in Pinia with Nuxt #1285

Jan 24, 2023 · 1 comments · 5 replies
Discussion options

You must be logged in to vote

The problem is const currentUser = await getCurrentUser(); the setup function of a store must be sync. Use the current user instead. You shouldn't have a conditional return in a setup function either, it's just not meant to be used that way. What is exposed should be stable.

const currentUser = useCurrentUser()
const userDocRef = computed(() => doc(db, 'users', currentUser.value?.uid))
const user = useDocument(userDocRef)

return { user }

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@davidstackio
Comment options

@posva
Comment options

@davidstackio
Comment options

@posva
Comment options

@davidstackio
Comment options

Answer selected by davidstackio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants