Wikipedia api help

for some reason i cant seem to understand how the wikipedia api works, right now im just trying to achieve a response but i cant even accomplish that. below is my codepen with the code im using! please help!!!

using opensearch will give you an array of all the matches that start with a certain word. IMO, that’s not the best idea because, as you see, you will get some weird results for “cat”.
To be honest, i found the wikipedia API quite hideous and user-unfriendly. Spent a lot of time googling until I found a way to do it that did what i wanted to do.

Now, regardless of what arguments you use, chances are you will be getting some form of JSON array. You have to iterate that array (look into “each()”). The array will be the different entries. In each element, you should retrieve the title, content and ID. The ID is what’s used to get the new url (the one that will be linked to from your page), the tile and content are what’s shown on your page.
This is similar to the weather app, in which you had a JSON array with different elements: temperature, wind, etc. Only that now you would have an array or arrays because you will retrieve a bunch of matches for each query

It looks like you’re response is working as it’s querying ‘cat’ and the JSON.stringify is outputting to the web page.

I think it’ll be easier to see the response structure if you did a console.log(data) instead of JSON.stringify(data) and looking at the console log of your browser. Stringify combines all the arrays together as one large string and its hard to see where one array ends and another begins.

Basically when using opensearch, the response for the first array is the query you sent to Wikipedia, the second array are the titles of the results up to a max of 10, the third array are the descriptions of the results up to a max of 10, some of them don’t have a description, and the fourth array are the URLs pointing to each article.

The documentation is huge. I found this particular page to be most helpful.
For me, the best way to get a handle on the json is to try typing the URL from your get request directly into a browser window, that will let you see the response without coding anything. To make it even more digestible, try copying it into a json viewer like this one. That will let you see the structure really simply.