I am toying around with the wiki API and trying to have an array of links from a given article returned. This is the kind of JSON i am working with:
{
"continue": {
"plcontinue": "22989|0|2007_Rugby_World_Cup",
"continue": "||"
},
"query": {
"normalized": [
{
"from": "paris",
"to": "Paris"
}
],
"pages": {
"22989": {
"pageid": 22989,
"ns": 0,
"title": "Paris",
"links": [
{
"ns": 0,
"title": ", Île-de-France, Seine, Kingdom of France"
},
As you can see I need to know the pageId for me to access the links array that I need. I tried extracting it from the plcontinue value and then have it inserted later in my code, but it returns an undefined.
This is my API request:
$.ajax({
url: "https://en.wikipedia.org/w/api.php?action=query&titles=" + searchTerm + "&pllimit=50&prop=links&format=json",
method: "GET",
dataType: "jsonp" //allow CORS
}).then(function (data) {
var plcontinueArray = data.continue.plcontinue.split("|")
var pageId = plcontinueArray[0];
var links = data.query.pages.pageId.links;
How do i access the array of links when i do not know the pageId before making the request?