Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

68
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda