-2

I am currently working on a telegram bot, and I want to add a function that can search Wikipedia, and I want to know how to get the 'extract' part without knowing the pageid from this wiki API that I fetch from URL?

For example this one: https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro&explaintext&redirects=1&titles=wiki&utf8

Niroshan Ratnayake
  • 3,433
  • 3
  • 20
  • 18
Jim
  • 33
  • 7

1 Answers1

-1
Object.keys(data.query.pages).map(pageId => data.query.pages[pageId]).map(page=>page.extract)

where data is the json you got

adajoy MC
  • 61
  • 4