I am trying to display just the JSON data that I get from the api call to wikipedia but it’s not displaying. I will take care of sorting out the info that I get from the api call later. I just want to get this step to work.
Here is a link to my codepen. Could someone please take a look at my code. Many thanks.
data.query.pages[pagenum]
is undefined, so nothing is displayed on the page. If you tried to inspect the data.query.pages
object in the console, you’ll see that it has a number of objects that can be accessed with numeric keys.
Try running this code in the function callback:
for (let id in data.query.pages) {
console.log(data.query.pages[id]);
}
I tried out your page, and as far as I can tell your ajax request isn’t sending back any usable data. I found the Wikipedia API really difficult to understand- I definitely recommend going to the sandbox and playing around for a while to really understand how the query needs to be formatted to work properly.
1 Like