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

505
Views
¿Hay alguna manera de moverse usando 'esperar' aquí?

Estoy tratando de obtener todos los documentos en una subcolección siguiendo la documentación de firebase, sin embargo, aparece el error 'esperar es un identificador reservado'.

Este es mi código actualmente y no veo dónde se podría usar 'async' con await y la documentación no indica que se usaría.

 getAuth().onAuthStateChanged((user) => { if (user) { const app = initializeApp(firebaseConfig); const db = getFirestore(app); //reference to the subcollection of subjects in the user's document const subjectRef = collection(db, "users", auth.currentUser.uid, "subjects"); const querySnapshot = await getDocs(subjectRef); querySnapshot.forEach((doc) => { console.log(doc.id, "=>", doc.data()); }); } });

He intentado obtener todos los documentos con db.collection.('users').document(auth.currentUser.uid).collection('subjects').get() where db = getFirestore(app), sin embargo, esto no funciona ya que aparece el error 'db. collection no es una función' y cualquier solución que haya encontrado no es relevante ya que db se refiere a firestore, no a la base de datos en tiempo real.

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

0

Debe hacer que la devolución de llamada sea asíncrona:

 getAuth().onAuthStateChanged(async (user) => { if (user) { const app = initializeApp(firebaseConfig); const db = getFirestore(app); //reference to the subcollection of subjects in the user's document const subjectRef = collection(db, "users", auth.currentUser.uid, "subjects"); const querySnapshot = await getDocs(subjectRef); querySnapshot.forEach((doc) => { console.log(doc.id, "=>", doc.data()); }); } });
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!