Reputation: 31
I'm trying to access Wiki api with below query:
https://en.wikipedia.org/w/api.php?action=query&generator=search&gsrsearch=india&gsrnamespace=0&gsrlimit=5&origin=*&prop=extracts&exchars=200&exlimit=max&explaintext=1&exintro=1
I'm getting response, but when I'm using JSON.parse
to parse response Mozilla is displaying an error:
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
Upvotes: 1
Views: 177
Reputation: 2852
Try this:
https://en.wikipedia.org/w/api.php?action=query&generator=search&gsrsearch=india&gsrnamespace=0&gsrlimit=5&origin=*&prop=extracts&exchars=200&exlimit=max&explaintext=1&exintro=1&format=json
Add the format=json
query parameter. Otherwise you're getting HTML with embedded JSON
Upvotes: 2