I've been encountering some issues with my weather app project due to lack of clarity in my previous questions. To be more specific, every time I attempt to retrieve weather information in JSON format using the fetch
method, it keeps returning undefined. I'm building this app solely with pure vanilla JavaScript and utilizing Open Weather Map's API for data retrieval. I even tried switching to a different API (Free Weather API) but encountered the same issue with undefined responses. The websites themselves seem to be loading fine, leading me to believe that the problem lies within my code.
fetch('http://api.openweathermap.org/data/2.5/weather?q=Traralgon&appid=a211b9a621afd7714296d94616623dea&units=metric').then(function (response) {
console.log('success!', response.main);
}).catch(function (err) {
console.warn('Something went wrong.', err);
});