我正在尝试通过javascript提取从回购中获取一些数据。到目前为止,我已经
let dump = [ ];
fetch(endpoint).then(blob => blob.json()).then(data => dump.push(...data));
,端点为url。似乎将数据转换为可以在控制台中看到的数组:
[]
0: Object { city: "New York", growth_from_2000_to_2013: "4.8%", latitude: 40.7127837, … }
1: Object { city: "Los Angeles", growth_from_2000_to_2013: "4.8%", latitude: 34.0522342, … }
2: Object { city: "Chicago", growth_from_2000_to_2013: "-6.1%", latitude: 41.8781136, … }
3: Object { city: "Houston", growth_from_2000_to_2013: "11.0%", latitude: 29.7604267, … } etc
上面显示的是我是否console.log(dump)
但是,如果我尝试从中提取某些内容,例如dump[1]
,则控制台会显示为未定义。我在做什么错了?