我是firebase的新手,我正在尝试将我对firebase的API调用的响应转换为数组。
这是我的商店文件- jobs.js
async jobList({ commit }) {
try {
const response = await this.$fire.firestore.collection('Job').get()
response.forEach((doc) => {
// doc.data() is never undefined for query doc snapshots
console.log(jobs)
commit('SET_JOBS', jobs)
});
} catch (e) {
console.log(e)
}
},
这是我在控制台中得到的响应。
{company_logo: 'tubem Ipsum', salary: 60000, company_name: 'tubem Ipsum', description: 'tubem Ipsum', title: 'tubem Ipsum', …}
{salary: 7000, title: 'tubem Ipsum', company_logo: 'tubem Ipsum', description: 'tubem Ipsum', tag: 'tubem Ipsum', …}
{description: 'tubem Ipsum', tag: 'tubem Ipsum', company_logo: 'tubem Ipsum', salary: 40000, company_name: 'tubem Ipsum', …}
{company_logo: 'lorem impsm', description: 'lorem impsm', tag: 'marketing', company_name: 'lorem impsm', salary: 20000, …}
{salary: 30000, company_name: 'vubem Ipsum', title: 'vubem Ipsum', description: 'vubem Ipsum', company_logo: 'vubem Ipsum', …}
{title: 'tubem Ipsum', company_logo: 'tubem Ipsum', tag: 'tubem Ipsum', salary: 50000, company_name: 'tubem Ipsum', …}
1条答案
按热度按时间fquxozlt1#
试试这个:
也许不同的版本有不同的语法,但如果你的日志是正确的,这将工作