title: How to recurse asynchronously over API callbacks in node.js?
body: <p>An API call returns the next 'page' of results. How do I recurse over that result callback elegantly?</p>
  
  <p>Here is an example of where I need to do this:</p>
  
  <pre><code>var url = 'https://graph.facebook.com/me/?fields=posts&amp;since=' + moment(postFromDate).format('YYYY-MM-DD') + '&amp;access_token=' + User.accessToken;
  request.get({
      url: url,
      json: true
  }, function (error, response, body) {
      if (!error &amp;&amp; response.statusCode == 200) {
          _.each(body.posts.data, function (post) {
              User.posts.push(post); //push some result
          });
          if (body.pagination.next) { // if set, this is the next URL to query
              //?????????
          }
      } else {
          console.log(error);
          throw error;
      }
  
  });
  </code></pre>