I’m working with Open Weather API, but when i send an request for a city data, i get network error.
var apiKey = “b6278500dc4dc994511feaf7311bf025”;
function getWeather(city) {
var url = `https://api.openweathermap.org/data/2.5/weather?q=${city}&appid=b6278500dc4dc994511feaf7311bf025&units=metric`;
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.responseType = "json";
xhr.send(null);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
output_section.style.display = "block";
if (xhr.status === 200) {
var DATA = xhr.response;
var iconAlt = DATA.weather[0].description;
var iconImgSrc = `https://openweathermap.org/img/wn/${DATA.weather[0].icon}.png`;