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

67
Views
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 answers
Answer question

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 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!