title: Returning a value from 'success' block in JS (Azure Mobile Service)
body: <p>I have a rather simple getUser method that I'm having some trouble with. I am not deeply familiar with scopes and such in JS so this is giving me a head ache. Basically I want to fetch an object from the database and return it to the calling method:</p>
  
  <pre><code>function getUser(uid)
  {
      var result = null;
  
      var userTable = tables.getTable('Users');
  
      userTable.where({
          userId: uid
      }).read({
          success: function (results) {
              if (results.length &gt; 0) {
                  result = results[0];
                  console.log('userid'+result.id);
              }
          }
      });
      console.log('userid-'+result.id); // undefined!!
      return result;
  }
  </code></pre>
  
  <p>Also, returning from inside the success doesn't return from getUser, but just the function defined inside. I tried "result = function(results)" as well but it stores the defined function and not the return value.</p>
  
  <p>How am I supposed to do this?</p>