我想迭代所有用户的以下内容并列出他们的用户名。目前,我能得到的是一个包含大量以下信息的对象,我似乎无法做任何事情。我想做的是采取以下措施,获取他们的用户名并将这些用户名推送到一个数组中。有什么建议吗?
SC.get('/me/followings',function(followings) {
console.log(followings);
// For loop iterating through all of the user's followings
for(i = 0; i < followings.length; i++)
{
// Push all of these likes into the 'meGenrePref' array
console.log(followings[i].username);
}
});
答案 0 :(得分:1)
你走了:
var meGenrePref = [];
SC.get('/me/followings',function(followings) {
for(i = 0; i < followings.collection.length; i++) {
meGenrePref[i] = followings.collection[i].username;
}
});
产地:
["Tom Misch", "fabric", "SØNDER.", "NIGHT CULT FM", "Mafia Kiss", "PUNKS MUSIC (FREE DOWNLOADS)", "Beatslappaz", "UFO-PROJECT", "BICEP", "MARTEN HØRGER", "MattWills", "Negativ", "Ollie James", "Saucy Music", "Ben Read", "Barely Royal", "INKLINE", "Bunk Audio", "Isenb3rg", "BUNNIE", "Ones", "Bachelors Of Science", "Aurbs", "JoeK", "Gramatik", "Al Pack", "Anita Magenta", "Gold Panda", "Ride.", "LYD", "Delo", "DJOKO", "Hushh", "Fête", "NOVKA", "Plump Djs", "Jaded", "Nu Aspect", "Rico Tubbs", "Saucy Vibes", "Nayla", "SOUNDMOOSE", "The Busy Twist", "EskyBeat", "BLANDA", "Kimyan Law", "Chris Gresswell", "Night Bass", "Blu Mar Ten", "MassMatiks"]
答案 1 :(得分:0)
代码应
var users = [];
SC.get('/me/followings',function(followings) {
for(i = 0; i < followings.collection.length; i++) {
users[i] = followings.collection[i].username;
}
});