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

349
Visualizações
AWS Auth - useState Failure After Fetch

I still considered myself a newbie to React, AWS, as well as here, so forgive me if the format is not proper or if the question is not clear but I try my best.

I fetch user data on one React component and try to set user email as follows:

    const [email, setEmail] = useState("") //used for signup confirmation

    useEffect(() => {
        Auth.currentAuthenticatedUser({
            bypassCache: false //if true, it will call the latest user data.
        }).then(
            user => {
                console.log(user.attributes.email); //this one returns the e-mail address
                setEmail(user.attributes.email); // this one is supposed to setEmail to the e-mail address
                console.log(email); // this one returns empty string.
            })
            .catch(err => console.log(err));
    }, []);

I tried to generate a function outside useEffect, built an API and called user details from the API but nothing helped. Somehow it doesn't pull the e-mail detail. What am I doing wrong? Do you think it's an async/await fallacy or rather related to AWS API?

about 4 years ago · Santiago Trujillo
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