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

73
Vistas
I am trying to get firebase firestore documents and display some of its information on the browser

When I console.log the data I get from firestore inside the then() function as shown below, it displays the data without the problem. However, if I append that data in the peopleData variable and console.log the peopleData variable, I get an empty string.

let db = getFirestore();
let peopleCollection = collection(db, 'People');

getDocs(peopleCollection)
.then((people) =>{
    people.docs.forEach(person =>{
        let personData = person.data(person);
        console.log(`${personData.Name} is an ${personData.Occupation} aged ${personData.Age}`);
    })})
.catch(err =>{
    console.log(err)
})

Here I get an empty string logged

let peopleData = ``;
getDocs(peopleCollection)
.then((people) =>{
    people.docs.forEach(person =>{
        let personData = person.data(person);
        peopleData += `${personData.Name} is an ${personData.Occupation} aged ${personData.Age}`;
    })})
.catch(err =>{
    console.log(err)
})

console.log(peopleData);
about 4 years ago · Juan Pablo Isaza
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