[Fetch API] Access another link in the fetched data

Hello, I’m currently working on fetching Wikipedia API and so far it’s been successfully fetched. BUT I have no idea how I can access the link in the data below(that I marked with an arrow) and see the data.

Can you guys advise me on how I could do that?
Thank you in advance.

btn.addEventListener("click", () => {
  const searchValue = input.value;
  const url = `https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=${searchValue}`;
    .then((resp) => {
      return resp.json();
    .then((data) => {


Are you trying to retrieve the data in JSON format? I don’t know the wikipedia API, but I found this on SO → How to get Wikipedia content using Wikipedia's API? - Stack Overflow. Basically, you have to use the end point query with parameters to retrieve the parts of the content you want. Specifically, you need to use the prop=revisions: http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&rvsection=0&titles=pizza

If you require the HTML, you could make another request and fetch it instead, parsing it with something like cheerio js and extract the sections you want.

1 Like

Hello Nicolas! Thank you for your kind reply with nice advice!
That’s right !! I was trying to retrieve the data in JSON format !!

I think I should look into the links you introduced first!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.