fetch('https://en.wikipedia.org/w/api.php?action=query&titles=Main%20Page&prop=revisions&rvprop=content&format=json')
.then(
function(response) {
if (response.status !== 200) {
console.log('Looks like there was a problem. Status Code: ' + response.status);
return;
}
// Examine the text in the response
response.json().then(function(data) {
console.log(data);
});
}
)
.catch(function(err) {
document.write('Fetch Error :-S', err);
});
The fetch address I'm using is listed here: https://www.mediawiki.org/wiki/API:Main_page under simple sample. Currently it catches on the error on the bottom with TypeError: NetworkError when attempting to fetch resource.
So far I've been unable to access any data from the API after trying different things with fetch()
Any help would be appreciated!
The project is on codepen here: http://codepen.io/javascriptisscary/pen/RazKWB