1

我正在使用 mailchimp 显示来自观众的所有电子邮件地址,为此,我正在使用以下代码:

const client = require("@mailchimp/mailchimp_marketing");

client.setConfig({
apiKey: "MY API KEY",
server: "MY SERVER",
});

const run = async () => {
const response = await client.lists.getListMembersInfo("LIST MEMBERS CODE");
i = 0
while (i < response.members.length){
   finalObject = Object.values(response.members[i]);
   console.log(finalObject[1]);
   i++
   }
};

run();

“MY API KEY”、“MY SERVER”和“LIST MEMBERS CODE”在这里是假的,我的代码中有真实的。

我的问题是终端只显示 10 个项目,而我有 1058 total_items。我知道问题是count 默认情况下是 10,但我不知道如何更改它,因为我没有任何 URL 来调用 API。

有没有其他方法可以通过更改数量来显示所有项目count

我也知道要显示的最大项目是 1000,所以我必须执行两次才能显示所有 1058 个项目。

4

1 回答 1

2

Examination of the relevant method here indicates that you can supply a second parameter, an object. In your case, it would be:

{'count': 1000}

Thus the call would be:

const response = await client.lists.getListMembersInfo("LIST MEMBERS CODE", {'count': 1000});

See MailChimp API Reference for more parameters.

于 2021-01-17T11:05:22.847 回答