marshallswain/feathers-pinia

Error in authStore Example for Vite

ericuldall opened this issue · 4 comments

// 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()

Same thing with Nuxt example.

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.

I had caught that one and changed it earlier (it was less subtle)

This is fixed in the 3.0 docs.