1

I have a script to to get all channels in my twilio service using the REST API. I was trying to find out a better way to fetch my channels rather than the approach that I'm following right now. This is my current approach

chatService
  .channels
  .list({
    pageSize: 1000
  })
  .then(channels => {
    //Work with the entire list of channels
  })

This approach works fine for me. But as the number of channels increase, I noticed that the time taken for this call increases and also at times I get socket timeouts. So I was trying to change this approach to page by page fetch in batches of 100. So I tried the following to get the 3rd page of 100 sets

chatService
  .channels
  .page({
    pageSize: 100,
    pageNumber: 2
  })
  .then(channelPage => {
    //channelPage.payload should give me the 3rd page of 100 results
  })

The problem I'm facing here is that irrespective of the value of the pageNumber, I'm always getting the first page of 100 results. I was not able to find any documentation on paginating by pages with the rest api. Is there some documentation around this? Is there anything wrong with the approach I've taken here?

Jophin Joseph
  • 2,864
  • 4
  • 27
  • 40

0 Answers0