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

636
Visualizações
AsyncStorage always returns {"_U": 0, "_V": 0, "_W": null, "_X": null}
async function getTokenFromAsync() {
  const userToken = await AsyncStorage.getItem('@User_Token');
  return userToken;
}

export default {getTokenFromAsync};

Im trying to get userToken from asyncStorage but it return me this {"_U": 0, "_V": 0, "_W": null, "_X": null}, Im using react native

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You are not resolving the Promise hence your "weird" output.

This is the way that I have my get Function defined:

  const getData = async (key) => {
    // get Data from Storage
    try {
      const data = await AsyncStorage.getItem(key);
      if (data !== null) {
        console.log(data);
        return data;
      }
    } catch (error) {
      console.log(error);
    }
  };

You can then get the Data by calling the Function with your Key.

  await getData("yourKey")
  .then(data => data)
  .then(value => {
    a state or constant = value
    console.log("yourKey Value:  " + value)
  })
  .catch(err => console.log(err))
about 4 years ago · Juan Pablo Isaza Relatório

0

You should wait to resolve the promise where you are using it like

getTokenFromAsync().then((userToken)=>{
  console.log(userToken);
});
about 4 years ago · Juan Pablo Isaza Relatório
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