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

183
Views
Firestore Firebase retrieving a array in a collection

I am trying to view or retrieve all the contents of the array in my collection, I am using reactjs and firebase this is my code

async function getData(){
  const productreference = collection(firestoredb, "Orders",`${userID}`,"Orderlist" );
  const q = query(productreference);
  onSnapshot(q,(snapshot) => 
    console.log(snapshot.docs.map((doc) => ({ ...doc.data().Data })))
  )
}

result

If I try this

async function getData(){
  const productreference = collection(firestoredb, "Orders",`${userID}`,"Orderlist" );
  const q = query(productreference);
  onSnapshot(q,(snapshot) => 
    console.log(snapshot.docs.map((doc) => ({ ...doc.data().Data[0] })))
  )
}

it will just show the entire content of the array 0 per document

This is my database structure:

database structure

This what I did

const [data, setData] = useState([]);
async function getData(){
  const productreference = collection(firestoredb, "Orders",`${userID}`,"Orderlist" );
  const q = query(productreference);
  onSnapshot(q,(snapshot) => 
    setData(snapshot.docs.map((doc) => ({ ...doc.data().Data })))
  )
  console.log(data)
}

this is the result of the console.log results

so how can i show the content of the "Data" per document

about 4 years ago · Juan Pablo Isaza
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!