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

160
Views
Is it a bad practice to use Promise just to chain the excecution in the proper sequence?

I'm developing an app with a Sign In with Google Firebase. I've got the need to update de current user data wich exists within a Auth Module when a user sign in, and then chain the execution of stuff with that specific data. Something like this :

fbAuth.signInWithGoogle()
.then(()=>{
    let user = fbAuth.getCurrentUser()
    console.log(user);
    fbFirestore.postDocToExistingGroup("projects", user.uid, {user: user.uid, test:true})
})

So I coded the function as a Promise inside a module Pattern function named fbAuth, but it seems to not be the best way for me:

const signInWithGoogle = function(){
        return Promise.resolve(
            signInWithPopup(auth, provider)
            .then((result) => {
            // This gives you a Google Access Token. You can use it to access the Google API.
            const credential = GoogleAuthProvider.credentialFromResult(result);
            const token = credential.accessToken;
            // The signed-in user info.
            const user = result.user;
            setCurrentUser(user)
            console.log("Signed In", user)
            // ...
            }).catch((error) => {
            // Handle Errors here.
            const errorCode = error.code;
            const errorMessage = error.message;
            // The email of the user's account used.
            const email = error.email;
            // The AuthCredential type that was used.
            const credential = GoogleAuthProvider.credentialFromError(error);
            // ...
            })
        )
    }

I did that just to be sure that I've got the current user data to execute the rest of the code using that data and not because the function its suposed to be a Promise from the beginning.

about 4 years ago · Juan Pablo Isaza
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!