I am working with Firebase Firestore using Nuxt js and I want to retrieve data from my database. I am using firebase with NuxtFirebase, the official plugin for firebase. Though I get a list of objects instead of an array, how do I convert it into an array?
//post.js
const actions = {
// The Post list API
async postList({commit}){
try{
const req = await this.$fire.firestore.collection('Post').get()
req.forEach((doc) => {
// doc.data() is never undefined for query doc snapshots
const posts = doc.data()
console.log(posts)
commit("SET_POST", posts)
});
}
catch(e){
console.log(e)
}
},
};
export default {
state,
getters,
mutations,
actions,
}