question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pageSize opts not working

See original GitHub issue

Hello, I’m facing a wrong behaviour using the twilio-node sdk. If I try to retrieve the messages list from a channel setting a pageSize value, let’s say equal to 25, the result contains all the messages like if the pageSize option is ignored.

I tried using the REST api instead, specifying the ?PageSize=25 param, and all works fine since I get the first 25 messages and the link for the next page and so on.

How can I solve this? Thanks. Is there also a way to specify the starting page?

Thanks, Simone

Version: 3.30.3

Code Snippet

const twilio = require('twilio');

const accountSid = 'acc sid';
const apikey_sid = 'apikey sid';
const apikey_secret = 'apikey secret';

const client = new twilio.Twilio(apikey_sid, apikey_secret, { accountSid: accountSid });

client.chat
    .services('serviceSid')
    .channels(encodeURIComponent('channelSid'))
    .messages
    .list({pageSize: 25})
        .then(ch => console.log("CHANNEL:", ch))
        .catch(err => console.error("ERR:", err));

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
childish-sambinocommented, May 10, 2019

Ah, sorry. I misread. Try something like this:

try {
    const messages = client.chat
        .services('serviceSid')
        .channels(encodeURIComponent('channelSid'))
        .messages;

    const page0 = await messages.page({ pageSize: 25 });
    page0.instances.forEach(message => console.log("MESSAGE:", message));

    // Get the next page.
    const page1 = await messages.getPage(page0.nextPageUrl);
    page1.instances.forEach(message => console.log("MESSAGE:", message));

} catch (err) {
    console.error("ERR:", err);
}

or

try {
    const page0 = await client.chat
        .services('serviceSid')
        .channels(encodeURIComponent('channelSid'))
        .messages
        .page({ pageSize: 25 });

    page0.instances.forEach(message => console.log("MESSAGE:", message));

    // Get the next page.
    const page1 = await page0.nextPage();
    page1.instances.forEach(message => console.log("MESSAGE:", message));

} catch (err) {
    console.error("ERR:", err);
}
0reactions
childish-sambinocommented, Aug 27, 2019

README updated with link for generated docs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Page Size Not Working - DevExpress Support
pageSize is one of the stored options. The state overrides the specified options in the grid. It's possible that your browser has an...
Read more >
PAGESIZE= System Option - SAS Help Center
Specifies the number of lines that compose a page of the SAS log and SAS output. Valid in: SAS 9.4: Configuration file, SAS...
Read more >
React Material Table pageSize is not updated dynamically
The pageSize property is initially defined as a state variable and updated based on selected pageSizeOptions. But the page size is not updated....
Read more >
Prismic API - pageSize not working
Hello @moorenmike, the team suggests two options: 1. getAllByType() with limit : getAllByType() will fetch all documents. To limit the number of ...
Read more >
PageSize, Top and MaxTop - OData - Microsoft Learn
The OData WebApi deals with client-driven paging using $skip and $top query options. The $top query option requests the number of items in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found