【发布时间】:2019-12-27 21:13:37
【问题描述】:
我正在处理从 Stripe 生成的客户 CSV 导入到 MongoDb 集合的数据。此 CSV 中的某些字段在名称中包含空格,例如 Card ID、Card Brand 和许多其他字段。
我在 .find() 查询的结果对象中访问这些名称时遇到问题:
StripeCustomer.find().then(
(customers) => {
console.log("customer[1]:", customers[1]);
console.log("id:", customers[1]['id']);
console.log("Card ID:", customers[1]['Card ID']);
res.json({
code: 200,
message: 'success',
total: customers.length,
data: customers
})
}
卡 ID 属性返回 undefined。
我尝试对属性名称 customers[0][encodeURIComponent('Card ID')] 使用 encodeURIComponent 或其他字符串转换函数,但没有结果。
【问题讨论】:
标签: node.js mongoose stripe-payments