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

139
Visualizações
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 à 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