Xero-api for pagination not working

345 Views Asked by At

I am using Xero as a trial version. I have 100+ contacts, Now I want to add pagination through NodeJS API. Read the documentation of it (https://developer.xero.com/documentation/api/contacts) it specify but doesn't work.

My code like this:-

let paging = await xeroClient.core.contacts.getContacts({page: 1})

I have call the function where passing page is a optional parameter but it display all the contacts for me.

Is there my mistake for passing parameter??

1

There are 1 best solutions below

0
On

I have not used node.js with XeroApi but from the documentation you can try the following:

/* Called per page */
const onContacts = (err, response, cb) => {
    let contacts = response.data;
    if (response.finished) // finished paging
        ....
    cb(); // Async support
};

xeroClient.core.contacts.getContacts({ pager: {start:1 /* page number */, callback: onContacts}})
    .catch(err => {
        console.log(`Oh no, an error: ${err}`);
    });

Check the part with the pager.