Wikipedia Viewer JSON

Wikipedia Viewer JSON


I’m trying to work through the JSON results of the Wikipedia API and output the relevant data, but I’m having a lot of trouble finding what I want in the JSON. I’ve tried using a FOR X IN Y loop, but I just get a list of numbers with no other internal structure. I can’t seem to work my way into the appropriate level of the JSON. If anyone has a chance to look at the Codepen and give me some advice, I’d really appreciate it.


try foreach, check the structure of what you get by simply opening the url you request in the browser like*&action=query&utf8&list=search&format=json&srsearch=horse you get the stringified json

the following instead of your success function works btw, types out the list of results and the snippets of text in the console

    success: function(data) { function(q) {


Thanks. I confess I searched around and looked at someone else’s code. I don’t know exactly how I was misinterpreting the JSON, but I think I understand how to loop through it now.