title: Getting constant value from asynchronous function
body: <p>Here is my code. </p>
  
  <pre><code>const fbLoginData= {}
  
  function _responseInfoCallbackID (error, result) {
    if (error) {
      fbLoginData.error="Unable to fetch data.Try again later or use other methods to sign-in"
    } 
    else {
      fbLoginData.id = result.id
      fbLoginData.email=result.email
      fbLoginData.name=result.name
      }
  }
  
  function _responseInfoCallbackPicture (error, result) {
    if (error) {
      fbLoginData.error="Unable to fetch data.Try again later or use other methods to sign-in"
    } 
    else {
      fbLoginData.profile= result.data.url
      }
  }
  
  export async function logInFB () {
  
      try{
        const login = await LoginManager.logInWithPermissions(["public_profile","email"])
        const value = await getValue(login)
        console.warn(" THE VALUE I AM SENDING ",value)
        return value
      }
  
      catch(error)
      {
        fbLoginData.error= "Unable to fetch Data"
      }
    }
  
  
  
  const getValue = (result)=&gt; {
    if (!result.isCancelled) {
      return AccessToken.getCurrentAccessToken().then(
        (data) =&gt; {
  
          fbLoginData.accessToken = data.accessToken
  
          const infoRequest = new GraphRequest(
            '/me',
            {
              accessToken,
              parameters: {
                fields: {
                  string: 'email,name'
                }
              }
            },
            _responseInfoCallbackID,
          );
  
          const pictureRequest = new GraphRequest(
            `/me/${PICTURE_PARAM}`,
            {
              accessToken,        
            },
            _responseInfoCallbackPicture,
          );
  
          // Start the graph request.
          new GraphRequestManager().addRequest(infoRequest).start()
          new GraphRequestManager().addRequest(pictureRequest).start()
          return  fbLoginData
        }
      )
    } 
  }
  </code></pre>
  
  <p>I want to have fbLoginData object to be filled with the data after having the callback functions <code>_responseInfoCallbackID</code> and <code>_responseInfoCallbackPicture</code> called. But the async function loginFB value doesn't return any other data than access token, but I want id, email, name that gets returned. I know the problem is due to asynchronicity, how can I get the fbLoginData with all the data I need? I cannot figure out the way I can do that. Any help on how to get the loginFB return the fbLoginData value with id,email,name and image that I want ?   </p>