If you’d prefer not to copy the example JSON you can still make an API call which returns a current JSON response with the live information.
This was tricky for me to figure out how to access since the API documentation on twitch is switching over to a new version and we’re being asked to use an external site to mine the older version of the API. To access the user list JSON you want to use these two URLs:
If you’re unsure of how to make basic API calls and retrieve JSON data there’s plenty of information about how to do that on the web. There’s a great section at the end of Code Academy’s beginner JS course that really cleared it up for me. You can use jQuery’s $.ajax (probably the easiest way for a beginner) or regular old JavaScript with the XMLHttpRequest object. One problem you might run into is that your calls will be asynchronous (returning once the request has finished) so whenever the data comes back you won’t be able to do anything with the data unless you explicitly instruct it to do so inside the request/response itself. The first thought is that maybe you should make them synchronous (which there is an option for in the XMLHttpRequest object) but this is NOT recommended since it will cause your page to hang while the data is loading. There are ways around this such as using .fetch and .then, Promises, or asnyc await functions.
thank you very much for your clear, complete and explicit answer. I thought I had missed something in the explanations and had read that there were problems with the twitch API. Only I found it stupid to build a code to give something instantaneous with false information. I think I’ll do it again and I’ll try to get it with $ get.JSON () or ajax request.