使用当前库版本2.11.2
,可以通过指定页码并在使用后使用.listBy
或使用分页对象https://github.com/intercom/intercom-node#pagination.list
来检索下一页(下面的演示代码)
var Intercom = require('intercom-client');
var client = new Intercom.Client({ token: TOKEN });
client.users.listBy({page: 1}, printDetails);
client.users.listBy({page: 2}, printDetails);
client.users.list(printDetailsAndGetNextPage);
client.users.listBy({page: 1}, printDetailsAndGetNextPage);
function printDetails(d){
var output = d.body;
console.log("Page: " + output.pages.page + " out of " + output.pages.total_pages);
}
function printDetailsAndGetNextPage(d){
var output = d.body;
console.log("Page: " + output.pages.page + " out of " + output.pages.total_pages);
if(output.pages.page < output.pages.total_pages) {
console.log("Getting next page...");
client.nextPage(output.pages, printDetails);
}
else {
console.log("No more pages left");
}
}