Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
Tom
@moT01
need to make them strings in the object, or create variables with those names
GabriRa
@GabriRa
Why when I use setState it doesn't triggers ComponentDidMount again?
Jose Diaz
@jsd540
thats what I want to end up with but it seems to be pushing to individual arrays
Tom
@moT01
@GabriRa i dont think it's supposed to trigger that
@jsd540 check it again
Marc
@MWBauer
Anyone have a moment?
Tom
@moT01
@MWBauer whats up
Marc
@MWBauer
I'm working on the Random Quote Generator. Once I've gone and pulled a random quote from the web, it needs to be displayed. Do I need a special field for that to display in, or make a button and have the message display there?
Tom
@moT01
@GabriRa i dont know spanish (i think that's spanish), so it's tough for me to find out what's going wrong there, but there should be single array that you map to the html in the return() and then in the function to update the grid you should change the state at the end, and it will automatically update the screen
pretty sure that's how i did it
@MWBauer make an html element to put it in
and use .html to put the quote in it
(if you're using jquery)
Marc
@MWBauer
thx
@moT01 thanks
CamperBot
@camperbot
sorry mot01, you can't send brownie points to yourself! :sparkles: :sparkles:
Jose Diaz
@jsd540
@moT01 yep still get 0 length, and [] in the console...
Marc
@MWBauer
What's the newest version of HTML?
Tom
@moT01
that's not what i got in the example i made @jsd540, do you have code i can see
5 @MWBauer
i think
Marc
@MWBauer
thx
Tom
@moT01
click my name
Jose Diaz
@jsd540

// list of active users from twitch

var userNameList = ['riotgames','syndicate','summit1g','esl_csgo',
'esltv_cs','nightblue3','imaqtpie','lirikk','lirik','sodapoppin',
'meclipse','cretetion', 'shroud','officialbjergsen','wolves_bjergsen',
'theoriginalweed','joshog','freecodecamp','Tsm_dyrus','dyrus','gosu',
'dreamhackcs','timthetatman','ESL_SC2', 'captainsparklez','goldglove','boxbox',
'speeddemosarchivesda','gamesdonequick','sgdq','trick2g','nl_kripp','castro_1021',
'swiftor','c9sneaky','storbeck', 'doublelift_renamed300203','doublelift',
'drdisrespectlive','OgamingSC2', 'sivhd','iijeriichoii','faceittv','Faceit',
'faker','tsm_theoddone','izakooo','pewdiepie','eleaguetv','amazhs','Voyboy',
'cohhcarnage','%63ohhcarnage','pashabiceps','anomalyxd','ungespielt',
'Tsm_doublelift','mlg_live','mlg','trumpsc','trump','pgl','loltyler1',
'omgitsfirefoxx','kinggothalion','habathcx', 'thenadeshot','nadeshot',
'kittyplaysgames','kittyplays','yoda','stonedyooda','RobotCaleb', 'GiantWaffle',
'Gronkh','bobross','nick28t','noobs2ninjas', 'gassymexican','monstercat','cryaotic',
'montanablack88','a_seagull','m0e_tv','reckful','kaypealol','sovietwomble',
'ProfessorBroman','nickbunyun','nalcs1','starladder5','twitch','e3','tsm_bjergsen',
'forsenlol','yogscast','rewinside','zeeoon','legendarylea','markiplier',
'dansgaming','pokimane','froggen','olofmeister','towelliee','aphromoo',
'ninja','streamerhouse'];

// userNameList array size.

var size = userNameList.length;

$(document).ready(function(){

// active on click button

// $("button").click(function(){
//   $("button").removeClass("active");
//   $(this).addClass("active");
// });

// listen for a button click to call function

// iterate the userNameList array
// and get necessary data for each user

for(var i = 0; i < size; i++){

    // construct the url

    var user_name = userNameList[i];
    var user_url = 'https://wind-bow.gomix.me/twitch-api/users/';

    user_url += user_name + '?callback=?';

    $.getJSON(user_url, function (user_data) {

    var name = user_data.display_name;     // twitch streamer user name
    var name2 = user_data.name;            // twitch user name to be sent to isItLive
    var logo = user_data.logo;             // streamer logo image
    var bio = user_data.bio;            // streamer bio

    if (bio == null){ // handle null bio case
        bio = 'no bio available';
    }
    else{ // if bio is too long limit size 
        bio = bio.substring(0,125) + "...";
    }
    // send data to isItLive

    isItLive(name, name2, logo, bio);

    });        
}

});

// this function finds out weather the streamer is
// currently live or if they are off the air.

function isItLive(name, name2, logo, bio){

var user_stream_url = 'https://www.twitch.tv/' + name2; // cunstruct user stream url

// construct url

var stream_url = 'https://wind-bow.gomix.me/twitch-api/streams/';

stream_url += name2 + '?callback=?';

$.getJSON(stream_url, function(liveOrNot){

    // if the streamer is off the air liveOrNot returns null
    // else streamer is currently on the air

    if (liveOrNot.stream != null){

    console.log(name + "  " + bio + " On-line now!");


    }
    else{

     console.log(name + " " + bio + " Off-line!");

    }

});

};

Tom
@moT01
so your computer can run through code really fast, ...that for loop takes like no time. A getJSON request, however, takes a little more time
so why you aren't able to fill your array is cause the request hasn't returned any values before you try and push it to the array
Kaz Baig
@kbaig
@MWBauer 5 but it is generally assumed that this is the final 'version' -- features will get added over time but they won't increment the version number. This is evidenced by the doctype declaration being simply <!DOCTYPE html> as opposed to <!DOCTYPE html5>
Tom
@moT01
@jsd540 pretty sure that's the problem... change your for loop to a forEach loop
Jose Diaz
@jsd540
ah that makes sense, is there a way to sync so the loop waits for a reply
Marc
@MWBauer
I need guidance.
Tom
@moT01
@jsd540 that won't be the last time you come across that problem, you might want to figure out how to debug it, i would have console.log the userNameList[i], and also console log the returned data
Marc
@MWBauer
How do I get text from a website for the Random Quote Generator?
Kaz Baig
@kbaig
@MWBauer You would need to find a quote API
Tom
@moT01
and you would see a list of all the names before any data @jsd540
ehutchllew
@ehutchllew
@jsd540 I haven't done a RESTful call inside a for loop in a while, but you could try creating a promise, then once you get a response from the service you resolve it, and I believe that will sort of "pause" the for loop iterations.
@jsd540 or wrap your RESTful API call inside of an IFFE.
Jose Diaz
@jsd540
@moT01 @ehutchllew thanks guys, I'm gonna re-think this, at least I know what the problem is now...
CamperBot
@camperbot
jsd540 sends brownie points to @mot01 and @ehutchllew :sparkles: :thumbsup: :sparkles:
:cookie: 359 | @ehutchllew |http://www.freecodecamp.com/ehutchllew
:cookie: 878 | @mot01 |http://www.freecodecamp.com/mot01
Tom
@moT01
@jsd540 that forEach loop should fix it, should just need to swap out one line
but, there's other ways as well
ehutchllew
@ehutchllew
@jsd540 Yeah try what @moT01 is saying, the forEach looks at the actual value in the indices of the array rather than a 'counter'.
Jose Diaz
@jsd540
@ehutchllew @moT01 yes, I will try a for each... Dear diary today I learned about for each :) Thanks guys.
CamperBot
@camperbot
jsd540 sends brownie points to @ehutchllew and @mot01 :sparkles: :thumbsup: :sparkles:
api offline
api offline
B
@B-keen
'''