I am having trouble accessing specific values of an object I am creating from an API call. Essentially, I want to console log a specific object value, but all I'm getting is undefined
. Here's my code and a link to my project on codepen:
$(document).ready(function() {
var users = ["freecodecamp", "trymacs", "phonecats"];
var info = {};
var i;
var identifier;
for (i = 0; i < users.length; i++) {
$.getJSON("https://wind-bow.gomix.me/twitch-api/streams/" + users[i], function(json) {
identifier = json["_links"].self;
identifier = JSON.stringify(identifier);
identifier = identifier.substr(identifier.lastIndexOf('/') + 1);
identifier = identifier.slice(0, -1);
info[identifier] = JSON.stringify(json);
});
}
console.log(info.freecodecamp);
});
Also, note that if you just log info
the whole object looks fine.
Thanks in advance for any and all help!