0

I am new to firebase and I am trying to convert the response from my API call to firebase into an array.

Here is my store file - 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)
  }
},

Here is the response I get in my console.

{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 Answer 1

2

try this:

maybe different versions have different syntax but if your log is correct this will work

const jobs = response.map(item => item.data())
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.