【问题标题】:Xero-api for pagination not working用于分页的 Xero-api 不起作用
【发布时间】:2017-09-01 06:34:56
【问题描述】:

我正在使用 Xero 作为试用版。 我有 100 多个联系人,现在我想通过 NodeJS API 添加分页。 阅读它的文档 (https://developer.xero.com/documentation/api/contacts),它指定但不起作用。

我的代码是这样的:-

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

我已经调用了传递页面是可选参数的函数,但它会为我显示所有联系人。

是不是我传参数有误?

【问题讨论】:

    标签: node.js pagination xero-api


    【解决方案1】:

    我没有使用带有 XeroApi 的 node.js,但您可以从文档中尝试以下操作:

    /* 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}`);
        });
    

    用寻呼机检查零件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-10
      相关资源
      最近更新 更多