Twitch TV app - how can I improve it?

Twitch TV app - how can I improve it?
0

#1

Hello, guys!

My first post here and I really like this place. I managed to just finish my Twitch TV app and I would like to hear back from you how can I improve the code I wrote?

Here is my app:

I am trying to write my apps code in pure JavaScript code , not jQuery because I really would like to learn the basics first before moving on the easier options.

I basically wrote the same function 4 times to fetch data for all the channels I have in my app, but I am sure I should have been able somehow to make the work with less code/functions and I would really like to hear your opinion on that.

Every reply will be highly appreciated.

Also feel free to share how do you find the overall appearance/functionality/coding of my app, as my oldest apps, also visible in my CodePen profile (if you feel like checking them too).

Cheers!


#2

Instead of storing the entire url for each user in the streamUrl array, why don’t you just store the userNames. Then, in the window.onload function, you can loop through this array, calling a function called sendRequest (a modified version of one of your sendRequest functions) which takes an argument (let’s call it userrName) and builds the url during each call to the function sendRequest. You will have to modify your new sendRequest function to build the html for each user to display instead of directly referencing a hard-coded element (i.e. id=‘src1’). You could create the id of the element as you build the html dynamically. That way if you want to display 1000 users, you do not already have to create divs for each of the 1000 users in your html.

Unrelated to your JavaScript code, your project is very difficult to read on a mobile device or smaller width screen (see below).


#3

Thank you for the feedback!
I posted the question with exactly the same idea - I want to improve my function to be able to call it dynamically instead of what I’ve done. I am generally happy it works, because this is what I wanted, but now I want to improve it.

As for the design of the app… I am familiar with the flaws, and I do not know if I am on the right track, but I want to make things work first and then for sure I will spend some time to learn how to build my apps to be fully responsive.