title: Promise is undefined
body: <p>i want to change the function for using Promise to deal with the callback</p>
  
  <p>the result of fatch is like this</p>
  
  <pre><code>[{ href: 'http:/segmentfault.com/q/1010000002714413',
      title: 'js图片轮播' },
    { href: 'http:/segmentfault.com/q/1010000002714953',
      title: 'stackoverflow, segmentfault 之类的网站是如何实现在输入问题时，下方出现模糊搜索的结果提示？' },
    { href: 'http:/segmentfault.com/q/1010000002711687',
      title: 'js与局域网' } ]
  </code></pre>
  
  <p>at the first time , i use the module "q" to change the function</p>
  
  <pre><code>function fatch(url) {
  
      var deferred = Q.defer();
      superagent.get(url)
          .end(function(err, data) {
              if (err){
                  console.log(err);
                  deferred.reject(err);
              } 
              var $ = cheerio.load(data.text);
              var result = [];
  
              $('.question-stream .stream-list__item').each(function(index, ele) {
                  var $ele = $(ele);
                  var href = path.join(url, $ele.find('.title a').attr('href'));
                  var title = $ele.find('.title').text();
  
                  result.push({
                      href: href,
                      title: title
                  });
              });
  
              // console.log(result);
              deferred.resolve(result)
              return deferred.promise;
  
          });
  
  }
  </code></pre>
  
  <p>i expected that i can get the result by "then"</p>
  
  <pre><code>fatch(url).then(console.log(data),console.log(err));
  </code></pre>
  
  <p>but i'm fail :</p>
  
  <pre><code>TypeError: Cannot read property 'then' of undefined
  </code></pre>
  
  <p>and i try this way :</p>
  
  <pre><code>function fatch(url) {
  
  var promise = new Promise();
  superagent.get(url)
      .end(function(err, data) {
          if (err){
              console.log(err);
              promise.reject(err);
          } 
          var $ = cheerio.load(data.text);
          var result = [];
  
          $('.question-stream .stream-list__item').each(function(index, ele) {
              var $ele = $(ele);
              var href = path.join(url, $ele.find('.title a').attr('href'));
              var title = $ele.find('.title').text();
  
              result.push({
                  href: href,
                  title: title
              });
          });
  
          // console.log(result);
          promise.resolve(result)
          return promise;
  
      });
  
  }
  </code></pre>
  
  <p>but it didn't work as before..</p>
  
  <pre><code>TypeError: Promise resolver undefined is not a function
  </code></pre>
  
  <p>i changed the function like this , it's working :</p>
  
  <pre><code>function fatch(url) {
  
      var deferred = Q.defer();
      var result = [];
      superagent.get(url)
          .end(function(err, data) {
              if (err) {
                  console.log(err);
              }
              var $ = cheerio.load(data.text);
  
  
              $('.question-stream .stream-list__item').each(function(index, ele) {
                  var $ele = $(ele);
                  var href = path.join(url, $ele.find('.title a').attr('href'));
                  var title = $ele.find('.title').text();
  
                  result.push({
                      href: href,
                      title: title
                  });
              });
  
          });
      // console.log(result);
      deferred.resolve(result);
  
      return deferred.promise;
  
  }
  </code></pre>
  
  <p>and i want to get the result :</p>
  
  <pre><code>fatch(url).then(function(data){
      console.log(data);
  },function(err){
      console.log(err);
  });
  </code></pre>
  
  <p>i don't know why the data is []   ? </p>
  
  <p>actually , it's my first time use Promise and i'm confusing , how to use promise change the function , please help me and thanks a lot~</p>