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

133
Vistas
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
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