Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

221
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!