I'm using the following code
try {
const response = await fetch(endpoint);
if(response.ok) {
jsonResponse = await response.json();
return jsonResponse;
}
} catch(error) {
console.log(error.message);
}
to fetch weather info from openweathermap. When I run the program locally on my computer or using a local server with VSC I get a "NetworkError when attempting to fetch resource." error caught. When I input the URL (https://api.openweathermap.org/data/2.5/weather?q=Madrid&appid=...)straight into the web browser it shows me the content without any issues. I can't for the life of me figure out what I'm doing wrong. What am I missing? (the link is missing the api key for obvious reasons, but it's written correctly in the code)