【发布时间】:2013-06-19 00:27:48
【问题描述】:
API 调用返回下一个“页面”结果。如何优雅地递归该结果回调?
这是我需要这样做的示例:
var url = 'https://graph.facebook.com/me/?fields=posts&since=' + moment(postFromDate).format('YYYY-MM-DD') + '&access_token=' + User.accessToken;
request.get({
url: url,
json: true
}, function (error, response, body) {
if (!error && 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;
}
});
【问题讨论】:
标签: javascript node.js asynchronous