我正在尝试从票证主API控制台记录一个数组,但似乎只能记录该数组中的1个项目

问题描述 投票:0回答:2

我目前正在尝试将所有事件名称填充到控制台日志中,但是我只能显示一个。我知道为什么我只显示1个结果(因为我在数组中选择了对象0),但是我不确定如何使它们全部显示

下面的代码console.log("event:" + response._embedded.events[0].name);

pic of array

jquery api console.log ticketmaster
2个回答
1
投票

您可以做类似的事情:

console.table(response._embedded.events, ["name"])

0
投票

也许这吗?

console.log("events: " + response._embedded.events.map(e => e.name));
© www.soinside.com 2019 - 2024. All rights reserved.