Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

170
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda