title: How to pass promise result into outer function?
body: <pre><code>function readData(field) {
      var profileDatabase = firebase.database();
      var user = firebase.auth().currentUser;
      var name = user.email.substring(0, user.email.indexOf("@"));
      return profileDatabase.ref('/users/' + name + 'id').once('value').then(function (snapshot) {
          return snapshot.val()[field];
      });
  }
  </code></pre>
  
  <p>I want the readData function to return snapshot.val()[field], but Promise is asynchronous. How can I resolve that? </p>