[Vuejs]-Vuex/Firestore retrieve user data from another collection

0👍

In your current code, every time you call commit('SET_MEMBER_DETAIL', res.data()), you’re replacing the previous value of SET_MEMBER_DETAIL. You’ll want to implement SET_MEMBER_DETAIL as an array, and then push each new member to it. See for example the call to push in the answer here: Push to vuex store array not working in VueJS.

If retreiveMembers may be called multiple times, you’ll want to commit an empty array to the list whenever you re-run the query. Something like commit('SET_MEMBER_DETAIL', []) just before querySnapshot.forEach in your current code.

Leave a comment