Error in authStore Example for Vite
ericuldall opened this issue · 4 comments
ericuldall commented
// stores/auth.ts
import { defineStore, acceptHMRUpdate } from 'pinia'
export const useAuthStore = defineStore('auth', () => {
const { userStore } = useUserStore()
const { $api } = useFeathers()
const auth = useAuth({
api: $api,
userStore,
})
auth.reAuthenticate()
return auth
})
if (import.meta.hot) {
import.meta.hot.accept(acceptHMRUpdate(useAuthStore, import.meta.hot))
}
const { userStore } = useUserStore()
should bue const userStore = useUserStore()
gustojs commented
Same thing with Nuxt example.
gustojs commented
Actually, $api
also needs changing, since useFeathers
returns api
.
Also, the example feathers-pinia-vite
repo suggests return { ...auth }
instead of return auth
. Is that necessary?
I assume the difference with auth.reAuthenticate()
between Vite and Nuxt examples is because in Nuxt we're reauthenticating in a plugin rather than during store creation.
ericuldall commented
I had caught that one and changed it earlier (it was less subtle)
marshallswain commented
This is fixed in the 3.0 docs.