Cannot fetch data from Wikipedia API

let dataObj = [];
const query = 'marvel';
  .then(data => data.json())
  .then(data => dataObj.push(data))
  .catch(err => console.log(err));

This is the error that I receive:

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '' 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.

I set the mode to no-cors but still no luck.



Try adding the query parameter origin=* to help resolve the CORS issue:${query}&prop=revisions&rvprop=content&format=json&formatversion=2&origin=*

Hopefully that helps!


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.