Search code examples
angularjsapimediawikiwikiwikipedia

How to get data from mediawiki api using Angularjs?


While I try to access wiki api using Angularjs $http.get(), CORS issues occured. Here is my code

$http.get('http://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&exintro=&titles=India') .success(function(data){ console.log('data' +data); });

And this is the error message

XMLHttpRequest cannot load https://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&exintro=&titles=India. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.


Solution

  • Use JSONP for cross-site requests.