title: How to use async/await to retrieve value from AsyncStorage in react native by using function
body: <p>I have created prefsManager.js - Use for storing and retrieve data from AsyncStorage but I have faced a problem like when print log it return always undefined because of it is Async but I want to print the actual value in a log by the call of the function.</p>
  
  <pre><code>import { AsyncStorage } from 'react-native';
  import prefskey from '../utils/constants/prefskeys';
  
  const setValue = async (key, value) =&gt; {
      await AsyncStorage.setItem(key, value);
  }
  
  const getValue = async (key) =&gt; {
      let value = '';
      try {
          value = await AsyncStorage.getItem(key) || 'none';
      } catch (error) {
          // Error retrieving data 
          console.log(error.message);
      }
      return value;
  };
  
  const prefsmanager = {
      setValue,
      getValue
  }
  export default prefsmanager; 
  </code></pre>
  
  <p>I have used this in my Home.js when button press I'm calling this method.</p>
  
  <pre><code>_handlePress() {
  
          await prefsManager.setValue(prefskey.username, this.state.username)
  
          console.log("username =&gt;&gt;", await prefsManager.getValue(prefskey.username)); 
  
       }
  </code></pre>