title: Accessing AsyncStorage react native
body: <p>Hello I am new to react Native and I would like to access the user id that was stored to  react Native storage  so that I can pass it to the WebSocket connection but it is not returning the id</p>
  <p><strong>here is my sample code</strong></p>
  <pre><code>    import { io } from &quot;socket.io-client/dist/socket.io&quot;;
      import env from &quot;../utils/env&quot;;
      import AsyncStorage from &quot;@react-native-async-storage/async-storage&quot;;
  
      const getUserData = async () =&gt; {
        try {
           const value = await AsyncStorage.getItem(&quot;UserData&quot;);
              if (value !== null) {
        return value;
      }
    } catch (e) {
      // remove error
    }
  
    console.log(&quot;Done.&quot;);
  };
  
  getUserData().then((res) =&gt; {
    let response = JSON.parse(res);
    console.log(response._id);
  });
  
  let socket = io(`${env.DEV_SERVER_URL}`, {
    transports: [&quot;websocket&quot;],
    query: `mobileId=${getUserData().then((res) =&gt;{
        let response = JSON.parse(res);
        return response._id
    })}`,
  });
  
  export default socket;
  </code></pre>