title: Retrieving Extract from Wikipedia API
body: <p>So I get a JSON response which looks like this:</p>
  
  <pre><code>{
  "batchcomplete": "",
  "query": {
      "pages": {
          "97646": {
              "pageid": 97646,
              "ns": 0,
              "title": "Die Hard",
              "extract": "Die Hard is a 1988 American action film directed by John McTiernan and written by Steven E. de Souza and Jeb Stuart. It follows off-duty New York City Police Department officer John McClane (Bruce Willis) as he takes on a group of highly organized criminals led by Hans Gruber (Alan Rickman), who perform a heist in a Los Angeles skyscraper under the guise of a terrorist attack using hostages, including McClane's wife Holly (Bonnie Bedelia), to keep the police at bay.\nIt is based on Roderick Thorp's 1979 novel Nothing Lasts Forever, the sequel to 1966's The Detective, which was adapted into a 1968 film of the same name that starred Frank Sinatra. Fox was therefore contractually obligated to offer Sinatra the lead role in Die Hard, but he turned it down. The studio then pitched the film to Arnold Schwarzenegger as a sequel to his 1985 action film Commando; he turned it down, as well, and the studio finally and reluctantly gave it to Willis, then known primarily as a comedic television actor.\nMade for $28 million, Die Hard grossed over $140 million theatrically worldwide, and was given a positive reception from critics. The film turned Willis into an action star, became a metonym for an action film in which a lone hero fights overwhelming odds, and has been named one of the best action movies ever made. The film also ranks #29 on Empire magazine's 2008 list of the 500 greatest movies of all time. The film's success spawned the Die Hard franchise, which includes four sequels (Die Hard 2, Die Hard with a Vengeance, Live Free or Die Hard and A Good Day to Die Hard), video games, and a comic book."
          }
      }
  }
  }
  </code></pre>
  
  <p>Here is the link: <a href="https://en.wikipedia.org/w/api.php?format=jsonfm&amp;action=query&amp;prop=extracts&amp;exintro=&amp;explaintext=&amp;titles=Die%20Hard" rel="nofollow noreferrer">https://en.wikipedia.org/w/api.php?format=jsonfm&amp;action=query&amp;prop=extracts&amp;exintro=&amp;explaintext=&amp;titles=Die%20Hard</a></p>
  
  <p>And I want to just get the extract of the page. The trouble is I don't know the pageid until I get the response, and so cannot call the extract.</p>
  
  <p>To get the extract for this example I would have to do:</p>
  
  <pre><code>var data = JSON.parse(this.response);
  console.log(suggestionData.query.pages.97646.extract);
  </code></pre>
  
  <p>So I have tried to get the value of the page id by making it a variable to add into the query like this:</p>
  
  <pre><code>var data = JSON.parse(this.response);
  var pageid = [suggestionData.query.pages[0];
  console.log(suggestionData.query.pages. + pageid +.extract);
  </code></pre>
  
  <p>But this hasn't been successeful as the variable pageid comes up as:</p>
  
  <pre><code>"97646": {
              "pageid": 97646,
              "ns": 0,
              "title": "Die Hard",
              "extract": "Die Hard is a 1988 American action film directed by John McTiernan and written by Steven E. de Souza and Jeb Stuart. It follows off-duty New York City Police Department officer John McClane (Bruce Willis) as he takes on a group of highly organized criminals led by Hans Gruber (Alan Rickman), who perform a heist in a Los Angeles skyscraper under the guise of a terrorist attack using hostages, including McClane's wife Holly (Bonnie Bedelia), to keep the police at bay.\nIt is based on Roderick Thorp's 1979 novel Nothing Lasts Forever, the sequel to 1966's The Detective, which was adapted into a 1968 film of the same name that starred Frank Sinatra. Fox was therefore contractually obligated to offer Sinatra the lead role in Die Hard, but he turned it down. The studio then pitched the film to Arnold Schwarzenegger as a sequel to his 1985 action film Commando; he turned it down, as well, and the studio finally and reluctantly gave it to Willis, then known primarily as a comedic television actor.\nMade for $28 million, Die Hard grossed over $140 million theatrically worldwide, and was given a positive reception from critics. The film turned Willis into an action star, became a metonym for an action film in which a lone hero fights overwhelming odds, and has been named one of the best action movies ever made. The film also ranks #29 on Empire magazine's 2008 list of the 500 greatest movies of all time. The film's success spawned the Die Hard franchise, which includes four sequels (Die Hard 2, Die Hard with a Vengeance, Live Free or Die Hard and A Good Day to Die Hard), video games, and a comic book."
  }
  </code></pre>
  
  <p>I also want to use javascript and not jQuery etc.</p>