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

168
Visualizações
Save different values on Async Storage React Native

I'm making an app in which I'm trying to save data in the local storage of the phone. I'm using async storage for that but when I try to save a different value with a different key it just updates. Need help, please. Below is my read and write code.

 const storeData = async () => {
try {
  let id = (Math.random() + 1).toString(36).substring(7);
var id33 = id;
  const jsonValue = JSON.stringify(region);
  await AsyncStorage.setItem(id33, "Andres");
} catch (e) {
  // saving error
}

};

const fetchAllItems = async () => {
try {
  const keys = await AsyncStorage.getAllKeys();
  const items = await AsyncStorage.multiGet(keys);
  alert(items);
} catch (error) {
  console.log(error);
}

};

Thank you and sorry for bothering you.

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

0

Before I start console.log(e) your errors in try catch blocks when coding. Will save you time

I made a copy of your code based on the info you gave me, and everything works . Full example here (https://snack.expo.dev/dYwSij6kV) Click Editor on the very bottom then turn on panel and then click on logs to see the output.

I got the output so it is showing multiple keys.

►1:["tbl6ai","Andres"]
►2:["vd73b","Andres"]
►3:["uemcr","Andres"]
►4:["n5kie","Andres"]
►5:["EXPO_CONSTANTS_INSTALLATION_ID","3c2eee1f-f917-40ce-a9e6-ce73f83183b6"]
►6:["8a1cd","Andres"]
►7:["1d40y","Andres"]

I recommned going through every line of your code where you use async storage to see if your missing something. If that still doesn't fix it delete your node_modules and package-lock.json and run npm install.

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