[SOLVED] Wikipedia CodePen getJSON

[SOLVED] Wikipedia CodePen getJSON


getJSON is not running with the wikipediaAPI URL, where as it does run with other URLs.

What’s wrong with it? https://codepen.io/fredstidston/pen/BJgJGd?editors=1010


You have a CORS issue. This appears in the browser console:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://en.wikipedia.org/w/api.php?action=query&titles=Main%20Page&prop=revisions&rvprop=content&format=json&formatversion=2. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

Adding origin=* in the URL parameters should fix it.


Thank you. The fix is not woking though


You should already be getting a valid response. You can see it if you console.logged it: image.

Now you have to figure out how to display it on the page. Ping me if you get stuck on that.


Yes it works now. Thank you