Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vuexfire: Dispatching enhanced action not working #242

Closed
flatoy opened this issue Mar 4, 2019 · 1 comment
Closed

Vuexfire: Dispatching enhanced action not working #242

flatoy opened this issue Mar 4, 2019 · 1 comment

Comments

@flatoy
Copy link

flatoy commented Mar 4, 2019

Store:

let store = new Vuex.Store({
  state: { users: []},
  actions: {
    setUsers: firebaseAction(
      ({ bindFirebaseRef }, { ref }) => {
        bindFirebaseRef('users', ref)
     })
  },
  mutations: {...firebaseMutations}
})

App.vue

created() {
    this.$store.dispatch('setUsers', db.collection('users'))
  }

Then I get

vuexfire.esm.js?3317:527 Uncaught (in promise) TypeError: Cannot read property 'where' of undefined
at eval (vuexfire.esm.js?3317:527)
at new Promise ()
at bind (vuexfire.esm.js?3317:526)
at context.bindFirebaseRef (vuexfire.esm.js?3317:593)
at eval (store.js?c0d6:141)
at Store.firebaseEnhancedActionFn (vuexfire.esm.js?3317:596)
at Array.wrappedActionHandler (vuex.esm.js?2f62:721)
at Store.dispatch (vuex.esm.js?2f62:428)
at Store.boundDispatch [as dispatch] (vuex.esm.js?2f62:322)
at VueComponent.created (App.vue?234e:40)

I believe I've set it up correctly but I cant get it to work with Firestore.

@posva
Copy link
Member

posva commented Mar 4, 2019

if you extract ref from the payload you need to pass an object too:

this.$store.dispatch('setUsers', { ref: db.collection('users') })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants