There is a property called extracts which gives you the summary for WikiPedia pages. It can be obtained by adding &prop=extracts in the url call. I am accessing an array of results, and I observe that only few results has the extract and the rest don't. It is usually either the first or the last result.
Here is the sample code
$.getJSON("https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&gsrlimit=15&generator=search&origin=*&gsrsearch=" + searchTerm, function(data){
console.log(data);
$.each(data.query.pages, function (i) {
console.log(data.query.pages[i].extract);
});
});
Here is a screenshot of the console results
As you can see the extract property is missing for all the search results except the first one. Why is it so? And how do I correct this issue?
Okay so after referring to this question and the documentation. I made this call
$.getJSON("https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&exintro=1&excontinue=1&exlimit=max&gsrlimit=10&generator=search&origin=*&gsrsearch=" + searchTerm, function(data){
console.log(data);
$.each(data.query.pages, function (i) {
console.log(data.query.pages[i].extract);});});
Now the extracts for all the results are shown except the first and the last one.