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

130
Views
undefined is not an object with Async/Await method

I am implementing a login functionality with firebase and React Native and keep getting this error when I use async method:-

[Unhandled promise rejection: TypeError: undefined is not an object (evaluating 'result2.failed')]

export default async function login(credentials) {
    let result2= succeed();
    result2 = await handleLogin(credentials.email, credentials.password);
    if(result2.failed()){
       return fail({password: "Login failed"});
    }
    else{          
       return succeed();
    } 
}
const handleLogin = async(email,password) => {
    try{
        auth.signInWithEmailAndPassword(email, password)
        .catch(function(error) { 
                console.log(error); 
                return fail("failed");
         })

     }catch(e){
            return fail("An error occurred");
     }

Edit: I removed the try catch blocks and did:

auth.signInWithEmailAndPassword(email, password).catch(function(error) { console.log(error); return fail("failed");})
return succeed();

This seems to have solve that error but now my code is always returning succeed(). Any thoughts?

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!