无法从维基百科获取数据 API

Cannot fetch data from Wikipedia API

let dataObj = [];
const query = 'marvel';
fetch(`https://en.wikipedia.org/w/api.php?action=query&titles=${query}&prop=revisions&rvprop=content&format=json&formatversion=2`)
  .then(data => data.json())
  .then(data => dataObj.push(data))
  .catch(err => console.log(err));

这是我收到的错误:

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://s.codepen.io' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

我将模式设置为no-cors,但还是不行。

尝试添加查询参数 origin=* 以帮助解决 CORS 问题:

https://en.wikipedia.org/w/api.php?action=query&titles=${query}&prop=revisions&rvprop=content&format=json&formatversion=2&origin=*

希望对您有所帮助!