this is my code:
fetch("https://api-2445582011268.apicast.io/games/",{
method: 'GET',
headers: {
'user-key':'key',
'Accept': 'application/json'
}
})
.then(resp => resp.json())
.then(json => {
console.log('json',json)
})
When I try to bring the data with the fetch I get the following error:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin'
header is present on the requested resource. Origin .
and when I add "mode: 'no-cors'"
it resolves
and tried also to add the Access-Control-Allow-Origin but it did not fit anything, follow the same errors
fetch("https://api-2445582011268.apicast.io/games/",{
method: 'GET',
mode: 'no-cors', //here was added: mode:'no-cors '
headers: {
'user-key':'key',
'Accept': 'application/json'
}
})
.then(resp => resp.json())
.then(json => {
console.log('json',json)
})
the independent if I add or not the mode: cors
, I always get the following
error:
Authentication parameters missing
OPTIONS 403 (Forbidden)
Any idea of why?
Thanks in advance!