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

121
Views
How to access documents properties from collection firestore. reactjs

here is my code:

const posts = firestore.collection("posts");

    function myFunc() {
        posts.get().then((result) => {
            result.docs.forEach((post) => {
                console.log(post.poster);
            })
        })
    }

When I run this function it logs undefined for each document when inside the actual documents the poster property is set to a string variable.

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

0

To access collection/document data from firestore you need to call the function '.data()' when looping through the document results.

I've updated your code below which will console log the string value from the key 'poster' in the data object for each document in your 'posts' collection.

const posts = firestore.collection("posts");

    function myFunc() {
        posts.get().then((result) => {
            result.docs.forEach((post) => {
                console.log(post.data().poster);
            })
        })
    }

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!