Twilio nodejs客户端指定PageSize查询参数

根据文档,在做GET资源列表时,应该能够指定PageSize参数

https://www.twilio.com/docs/api/rest/response#response-formats-list-filters

你如何使用NodeJS客户端做到这一点? 要传递到/ Accounts / [AccountSid] / Messages / [MessageSid]的唯一可用参数是(from / to / dateSent)

您可以像这样指定页面大小:

client.messages.each( { pageSize: 10 }, (message) => console.log(message.body) ); 

这将使得多个请求获得所有的消息,并且每个请求将返回10条logging。

您还可以添加limit选项来限制返回的logging总数,以及您提到的其他filter参数。

 const accountSid = 'ACc0966dd96e4d55d26ae72df4d6dc3494'; const authToken = "your_auth_token"; const client = require('twilio')(accountSid, authToken); client.messages.each( { to: '+13335557777', limit: 30, pageSize: 10 }, (message) => console.log(message.body) ); 

默认值是“无限制”(将获得所有)的limit和50 pageSize