Twitch.tv API task

Twitch.tv API task
0.0 0

#1

Finished my twitch.tv api task and looking for feedback. Only thing is my links don’t seem to work for some reason, the url is right when i console log so i have no idea. Can anyone shed some light? The jscript that adds the links in html is in the functions at the top of the jss script.

Thanks in advance for the constructive criticism :smiley:


#2

The problem is your dispLive function (seen below).

function dispLive(live){
	var livht = '';
	for (let i = 0; i < live.length; i++){
		//console.log(live.url)
			livht += '<div class="box text-center live"><a href="'+live.url+'" target = "_blank"><h3>'+live[i].name+'</h3></a><h4>Game: '+live[i].game+'<br>Viewers: '+String(live[i].viewers)+'<br>Online</h4></div>'
	}
	return livht;
}

The live argument passed into the function is an array with three elements, yet inside your for loop, you do not reference each element. You just have live.url. Since live does not have a property named “url”, that is why the links end up with undefined on the end. You correctly referenced the elements when you display game, name, and viewers.


#3

Ah silly mistake. Thankyou :slight_smile: