我在获取维基百科时收到错误的响应 api

I get wrong response when i fetch wikipedia api

我在尝试使用维基百科时收到此回复 API > Response {type: "cors", url: "https://en.wikipedia.org/w/api.php?action=opensear…amespace=0&format=json&origin=*&utf8=&format=json", redirected: false, status: 200, ok: true, …}

正确的响应是 json 格式的请求数据,但我无法获取!

这是我的代码:

let link = `https://en.wikipedia.org/w/api.php?action=opensearch&search=google&limit=20&namespace=0&format=json&origin=*&utf8=&format=json`;
fetch(link)
.then((res)=>{console.log(res);return res;})

谁能帮帮我?

试试这个:MDN

let link = `https://en.wikipedia.org/w/api.php?action=opensearch&search=google&limit=20&namespace=0&format=json&origin=*&utf8=&format=json`;
fetch(link)
  .then(res => res.json())
  .then(data => console.log(data));

试试这个 Example

fetch('https://en.wikipedia.org/w/api.php?action=opensearch&search=google&limit=20&namespace=0&format=json&origin=*&utf8=&format=json')
  .then(function(response) {
    return response.json();
  })
  .then(function(myJson) {
    console.log(myJson);
  });