繁体   English   中英

检索所有客户的电子邮件地址条带 node.js

[英]retrieve all customers email address stripe node.js

我有这个功能,试图以条带形式检索所有客户的电子邮件:

 const customers = await stripe.customers.list({
  });

    var customerEmail = customers.data[0].email;
    console.log(customerEmail)

我正在尝试从条带中返回用户的所有电子邮件地址。 问题是,当我记录它时,它只返回第一个,因为我有data[0] 我需要所有这些,但我不能把它放在一个循环中,因为我在循环什么。 有没有办法正确地做到这一点?

您正在索引的data属性是一个可以迭代的数组[1]。

const customers = await stripe.customers.list({});

customers.forEach(customer => {
  console.log(customer.email);
});

[1] https://stripe.com/docs/api/customers/list

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM