hoemboy
1
This is my first time working with an api and JavaScript.
I have previous experience in Python so JS wasn’t that foreign to me but I still need a little help!
I have spent the last few days reading through all the information I can to make my script on my own but I guess it’s time to ask smarter people.
My goal is to pull data from https://api.twitch.tv/kraken/beta/streams/random , get data from only the first stream in the list/array/whatever-it-is (I’m still unsure what I’m looking at. They’re objects in a list, correct?), and then embed the player from that stream. I have the general concept in my head but don’t know exactly where to start.
Here is the structure I have so far. A little guidance would help a lot!
I guess what I’m trying to ask is:
- how the GET command is used to get the data
- how to parse/pick out the data that I want
3ventic
2
Since you’re using jQuery, take a look at jQuery.ajax with the jsonp dataType. Jsonp has to be used because the Twitch API doesn’t allow cross-origin requests. The callback function will get a decoded json object that you can then inspect in the browser’s dev tools.
hoemboy
3
So, I understand the request to get the decoded json object. I’m having difficulty trying to weed out the specific data I want. Also, is there a way to request the data I receive then print it on the webpage? Doing so would help me troubleshoot my problems.
night
4
Use the console to test and debug your JavaScript: https://developer.chrome.com/devtools/docs/console
hoemboy
5
Okay, I debugged to another point where I need help. The ajax call I make succeeds,
but now how do I cache or store the JSONdata I received into a variable?
system
Closed
6
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.