Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

338
Vistas
Firebase: How to log the value returned from Firebase collection?

In my React Native app I get a value from Firebase using

this.getRef()
.doc(<something>)
.collection(<something>)
.doc(<something>)

I want to log the value returned by that, but I don't know if it returns a promise. I'd like to do something like

let a = this.getRef()
  .doc(<something>)
  .collection(<something>)
  .doc(<something>)
console.log(a)

How should I approach this?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

At the moment, you just have a reference to the document, not the document itself. To get the document a single time, use .get. This will return a promise:

this.getRef()
  .doc(<something>)
  .collection(<something>)
  .doc(<something>)
  .get()
  .then(doc => {
    console.log(doc.data());
  })

// Or using async await:
const someFunction = async () => {
  const doc = await this.getRef()
    .doc(<something>)
    .collection(<something>)
    .doc(<something>)
    .get()
  console.log(doc.data());
}

Alternatively, if you want to continue listening for changes, use onSnapshot:

const unsubscribe = this.getRef()
  .doc(<something>)
  .collection(<something>)
  .doc(<something>)
  .onSnapshot(snapshot => {
    console.log(snapshot.data());
  });

// Later you can call unsubscribe() to stop listening
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda