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

639
Views
AsyncStorage always returns {"_U": 0, "_V": 0, "_W": null, "_X": null}
async function getTokenFromAsync() {
  const userToken = await AsyncStorage.getItem('@User_Token');
  return userToken;
}

export default {getTokenFromAsync};

Im trying to get userToken from asyncStorage but it return me this {"_U": 0, "_V": 0, "_W": null, "_X": null}, Im using react native

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You are not resolving the Promise hence your "weird" output.

This is the way that I have my get Function defined:

  const getData = async (key) => {
    // get Data from Storage
    try {
      const data = await AsyncStorage.getItem(key);
      if (data !== null) {
        console.log(data);
        return data;
      }
    } catch (error) {
      console.log(error);
    }
  };

You can then get the Data by calling the Function with your Key.

  await getData("yourKey")
  .then(data => data)
  .then(value => {
    a state or constant = value
    console.log("yourKey Value:  " + value)
  })
  .catch(err => console.log(err))
about 4 years ago · Juan Pablo Isaza Report

0

You should wait to resolve the promise where you are using it like

getTokenFromAsync().then((userToken)=>{
  console.log(userToken);
});
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!