WikiPedia Viewer: Getting snippet/extract consistently

WikiPedia Viewer: Getting snippet/extract consistently
0.0 0

#1

Hi,

I’m playing with the Wikipedia API (finding it really hard?) and struggling to get the image and extract/snippet from the results. I tried using list=search at first and I like the snippet this returns, but I decided I wanted to get a) images and b) the canonical URL, too. So I added extracts to my query too (as described here http://stackoverflow.com/questions/25891076/wikipedia-api-fulltext-search-to-return-articles-with-title-snippet-and-image) but it’s not behaving as expected. It is working in some cases but a lot of the results return ‘undefined’ for extract. I’m not getting as consistent results as I did using snippet from list=search.

Here’s my current work-in-progress (not nearly finished yet!): http://codepen.io/sarahessex/pen/woBraN an example of undefined is if you search for ‘elizabeth’.

My params are in the genParams variable and when you run the code you can open the sandbox API using the “Open Sandbox” link.

I tried to use gsrprop snippet too but it doesn’t seem to make any difference. Very confused by the API in general to be honest…

Any help with getting more consistent snippets would be much appreciated…