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

72
Vistas
Converting chained then statements into promise.all

I have a three-step process that needs to run synchronously. First, the app pulls information from one firebase collection, then using that result, pulls information from a second collection, then using that result, performs a function.

These are not running synchronously, so I'm missing the data assignments.

I believe the solution is working with promise.all, but I cannot structure it correctly:

Original Code:

 getUserInfo(user)
   .then(() => {
      //get data from database from result of getUserInfo
       getStyles(userInfo.value);
    })
   then(() => {
      //do things with data from database from result of 
      getStyles
       console.log(info);
        });

With Promise.all:

 let newUser = getUserInfo(user);
 let newStyles = getStyles(userInfo.value)

 Promise.all([newUser, newStyles]).then(() => {
   console.log("do things")
  }

The error is that the value newUser is still undefined.

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

0

It seems like you forgot to return anything from your promises so all you get is undefined.

Try like this.

getUserInfo(user)
   .then((userInfo) => {
      //get data from database from result of getUserInfo
      return getStyles(userInfo.value);
    })
   then((stylesInfo) => {
      //do things with data from database from result of getStyles
       console.log(stylesInfo);
   });
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