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

223
Visualizações
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 Respostas
Responde à pergunta

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 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