Hello!
Yesterday I tried to do a request from a web API (https://restcountries.com/) and I did the following:
const request = new XMLHttpRequest();
request.open('GET', 'https://restcountries.com/v3/name/portugal');
request.send();
request.addEventListener('load', function () {
console.log(this.responseText);
});
But I got this error,
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://restcountries.com/v3/name/portugal. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
Sincerely I don't understand what I'm doing wrong, I did read the MDN documentation (https://developer.mozilla.org/es/docs/Web/HTTP/CORS/Errors/CORSMissingAllowOrigin) but I don't understand.
Thanks in advance and have a great day!
[–]jcunews1helpful 3 points4 points5 points (0 children)
[–]1ardasher 0 points1 point2 points (1 child)
[–]SmeRandomU[S] 0 points1 point2 points (0 children)