Wikipedia Viewer review and help


This is a link to my project. My problem is that I am unable to display more than 10 results.

https://en.wikipedia.org/w/api.php?action=opensearch&search=hi&format=json&callback=?
^ This is a sample of my url that is generating the search. If I use query instead of open search I am able to get a lot more results but then the problem is that a simple for loop is inefficient in displaying more than 10 results. I want to display all the queries and their wiki link. I want to make it look like a google search.
Please advise

How is a simple for loop inefficient in a query?
var pages = json.query.search.length; for (var index = 0; index < pages; index++) { //wahteva }

It is not working. Maybe the problem is on my end but every time I include that logic in my js code. It will not load my page after saving it. So I am guessing maybe that this logic is inefficient.

Thanks for the quick reply

Hi, :slight_smile:

``http://codepen.io/erretres/pen/XKkyOj

I changed (added “&limit=20”):
var URL = “MediaWiki API result - Wikipedia” + item + “&limit=20&format=json&callback=?”;

Documentation:
https://www.mediawiki.org/wiki/API:Opensearch

Parameters:

limit
Maximum number of results to return.
No more than 100 (100 for bots) allowed.
Type: integer or max
Default: 10

3 Likes