1👍
✅
In each iteration of the forEach()
you overwrite the items
variable with doc.data()
;
Using the push()
method, as follows, should do the trick:
setMovies(state){
let items = [];
db.collection('movies').onSnapshot((snapshot) => {
snapshot.docs.forEach((doc)=>{
// eslint-disable-next-line no-console
console.log(doc.data())
items.push(doc.data())
});
state.movies = items;
})
}
Source:stackexchange.com