我正在向YouTube playlistItems API发送GET请求并获取数据对象,之后我在$ .each()循环的帮助下遍历所有项目,并在循环中添加每个元素(对象)进入一个新数组。我正在阅读该阵列时遇到麻烦任何帮助表示赞赏。 代码:
var videosArray = new Array();
$.get('https://www.googleapis.com/youtube/v3/playlists', {
'channelId': channel_id,
'part': 'snippet,contentDetails',
'key': api_key
}, function(data) {
$.each(data.items, function(i, item) {
videosArray.push(item);
});
现在,当我执行console.log(videosArray)
时,我得到一个对象[]
并且在其中我有数据在ket:value对中但当我尝试用另一个$ .each()循环读取它时没运气。例如:
0: {
kind: "youtube#playlistItem",
etag: ""xxsdasdasd"",
id: "asdasdad",
snippet: {...},
contentDetails: {...}
}
我在这个返回信息的例子中使用了伪数据。感谢任何帮助,谢谢!
以下是来自console.log(videosArray)的完整回复:
[]
0:{kind: "youtube#playlistItem", etag: ""m2yskBQFythfE4irbTIeOgYYfBU/3QUNPI_1luYHJPo518qq3Jud20E"", id: "UExFbW9VZld4dnFzXzNUbmptdi1GVk1OcHJ1dzZ0M3NQUC41NkI0NEY2RDEwNTU3Q0M2", snippet: {…}, contentDetails: {…}}
1:contentDetails:{videoId: "h9TAxR5wHwc", videoPublishedAt: "2009-08-24T19:02:49.000Z"}etag:""m2yskBQFythfE4irbTIeOgYYfBU/KSpBjTZ-G1a9DM0Pa1kR0rI1RYY""id:"UExFbW9VZld4dnFzLWNvQjJPY0dvdE1fV01rWERiTTN0WC4yODlGNEE0NkRGMEEzMEQy"kind:"youtube#playlistItem"snippet:{publishedAt: "2016-09-01T07:48:18.000Z", channelId: "UCBufHAyKSaGBAIqfjURXCXw", title: ""Yagudky". DakhaBrakha", description: ""Yagudky". DakhaBrakha band (Kyiv, Ukraine)↵http://www.dakhabrakha.com.ua/", thumbnails: {…}, …}
__proto__:Object