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

113
Visualizações
react-native async storage is not saving and no errors

Async storage is not saving. error is empty

i try to store deviceId in async storage but function setItem is not working

import AsyncStorage from '@react-native-async-storage/async-storage';

const store = async (uniqueId) => { 
const jsonValue = JSON.stringify(uniqueId)
   try {
      await AsyncStorage.setItem("@user", jsonValue, (e,r)=>{ 
        console.log("error: " ,e) 
        return r
      });
   } catch (e) {
      console.log("error: ", e) 
   }
      console.log("get Item: " , AsyncStorage.getItem("@user"))
}
store()
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

getItem is an async function, so you need to add await before like below:

const user = await AsyncStorage.getItem("@user")
console.log("get Item: ", JSON.parse(user))

Or:

AsyncStorage.getItem("@user").then((user)=>console.log(JSON.parse(user)))

But other than that, I think it's not saved when you call it and the way you call the function is wrong.

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