While debugging my JavaScript code in the console, I keep encountering an error. Here's the snippet of code I'm working with:
const request = new XMLHttpRequest();
request.open('GET', 'https://restcountries.eu/rest/v2/name/portugal');
request.send();
request.addEventListener('load', function () {
console.log(this.responseText);
});
I was hoping to retrieve information about a specific country from the server and display it in the console. Could the issue be related to the URL that I'm using? I've attempted replacing "portugal" with other country names, but the error persists!