title: Promise returning undefined
body: <p>I am trying to use promise to send an ajax request to a php script which checks if a file exist on the server and returns a boolean value.</p>
  
  <p>I have the below code but the fileExists function always return undefined.</p>
  
  <p>How can I wrap the promise in a function and have the function return the promise value?</p>
  
  <pre><code>function fileExists(url) {
      var promise = new Promise(function(resolve, reject) {
          var xhr = new XMLHttpRequest();
          xhr.onload = function() {
              resolve(this.responseText);
          };
          xhr.onerror = reject;
          xhr.open('GET', url);
          xhr.send();
      }); 
      promise.then(function(e) {
          return e;
      });
  }
  
  var result = fileExists("url_to_file");
  </code></pre>