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

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

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