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

225
Vistas
Add new data in Async Storage React Native

Sorry to bother you but Im new at React Native. I can save data in Async Storage with a random key but when I try so save more data in a different key (dince is random) it only displays the new one. I want to display all the data. Heres my code:

When I save

const storeData = async () => {
    let id = (Math.random() + 1).toString(36).substring(7);
    var id33 = id;

    setId3(id33);
    const jsonValue = user + id33 + newdate2 + id33;

    const jsonValue4 = jsonValue;

    await AsyncStorage.setItem("user", jsonValue4);
    //await AsyncStorage.setItem("date", jsonValue2);
    //await AsyncStorage.setItem("id", jsonValue3);
    getData();
    //getData2();

    alert(jsonValue);
};

When I read:

const getData = async () => {
    const value = await AsyncStorage.getItem("user");
    const value4 = JSON.parse(value);
    setValue2(value4);
};
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Because all the values you store on asyncStorage, you've stored on location 'user' and you're asking your codes to give you back data from location 'user' so it'll give you back the same value you stored in

but if you've putted other values on keys other than 'user' you can get all the keys in a array using

var keys = await AsyncStorage.getAllKeys()

and request the values using multget api of asyncStorage as below

 var keys = await AsyncStorage.getAllKeys();
 var values = await AsyncStorage.multiGet(keys);
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