I know this issue has been asked before but I'm having trouble really understanding what the issue is or exactly how to fix it. I'm fairly new to JavaScript and I'm trying to mess around with this API. I'm first just trying to grab the title of a game and display it in the console when I click a button. Whenever I click the button, in the console I receive:
"CORS header ‘Access-Control-Allow-Origin’ missing"
as well as:
"TypeError: NetworkError when attempting to fetch resource."
scripts.js
function getGame() {
fetch('https://zelda-api.apius.cc/api/games')
.then(function (response) {
return response.json();
})
.then(function(data) {
// appendData(data);
console.log(data)
})
.catch(function (err) {
console.log('error: ' + err);
});
}
I've tried doing variations like:
fetch('https://zelda-api.apius.cc/api/games'{
mode: 'cors',
headers: {'Access-Control-Allow-Origin': '*'}
})
Again, I know this isn't a new problem but I'm having trouble adapting all the other answers to my situation. I appreciate the help!