title: Chaining in Promise not working as expected
body: <p>I'm facing an issue with promises..and was banging my head around from almost an hour now...</p>
  
  <pre><code>this.getDocument(documentId)
  .then(function (response) {
       console.log('in first then')
       return 'from first then';
  }).then(function (response) {
       console.log(response)
  });
  </code></pre>
  
  <p>Ideally the above code should give following output</p>
  
  <pre><code>  in first then
    from first then
  </code></pre>
  
  <p>But the actual output is as follows</p>
  
  <pre><code>  in first then
    undefined
  </code></pre>
  
  <p>Now the problem here is why the second <code>then</code> is getting response as undefined when I'm returning something from the first <code>then</code>.</p>
  
  <blockquote>
    <p><strong>[EDIT 1]</strong> Adding getDoument code</p>
  </blockquote>
  
  <pre><code>function getDocument(documentID) {
          var config = {
              url: '&lt;URL&gt;' + documentID,
              headers: {enter code here
                  'Content-Type': 'application/json'
              }
          };
          return HttpRequest.get(config);
      }
  
  var HttpRequest = (function () {
      function HttpRequest() {
      }
      HttpRequest.get = function (config) {
          var deferred = Q.defer();
          var http = new XMLHttpRequest();
          var url = config.url;
          var authToken = window.localStorage.getItem('token');
          http.open("GET", url, true);
          Object.keys(config.headers).map(function (k) {
              http.setRequestHeader(k, config.headers[k]);
          });
          http.setRequestHeader("Authorization", 'Bearer ' + authToken);
          http.onreadystatechange = function () {
              if (http.readyState !== 4)
                  return;
              var response = http.responseText;
              if (http.status != 200)
                  return deferred.reject(response);
              deferred.resolve(response);
              // if (/^[^2]\d\d$/.exec(http.status)) return deferred.reject(http.status);
          };
          http.send();
          return deferred.promise;
      };
      HttpRequest.post = function (config) {
      };
      return HttpRequest;
  }());
  </code></pre>