Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
Firebase Firestore - React.js - Get Singular Document Values by ID (Make it Return json Object)

I know this is probably really simple - but I'm horrendous at JavaScript and can't figure this out. Have been looking through other StackOverflow posts for a good hour and all "solutions" don't seem to work.

I have the below function - which returns what's shown in the image - but i'm not sure how to convert this into a json object that I can actually work with on the frontend.

Anyone know how to modify this in order to accomplish that?

  getTools = ({id}) => {
    let ref = this.write.collection('tools').doc(id)
    let results = []
    ref.onSnapshot(snapshot => {
      const id = snapshot.id
      const data = snapshot.data()
      results.push({...data, id})
      });
    return results
  }

enter image description here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Its returning nothing because the onSnapshot is an asynchronous event.

async function getTools(id) {
 let ref = this.write.collection('tools').doc(id)
 let results = await ref.onSnapshot(snapshot => snapshot.data()}
 return results;

}

Something like that.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!