fatch 사용
1fetch(API_URL_OpenWeatherMap)2 .then(function (resp) {3 return resp.json();4 })5 .then(function (json) {6 ...7 }
.then(function (json)){...}
내부 코드
1function renderWeatherData() {2 // 1️⃣ 날짜 표시3 {4 }5
6 // 2️⃣ 시간 표시7 setInterval(function () {8 time.textContent = new Date().format2();9 }, 1000);10
11 // 3️⃣ 온도 표시12 {13 }14
15 // 4️⃣ 아이콘 표시16 descriptionIcon.setAttribute(17 "src",18 `http://openweathermap.org/img/wn/${json.weather[0].icon}@4x.png`19 );20}
1️⃣ 날짜 표시
2️⃣ 시간 표시
setInterval()
사용, 1초마다 업데이트3️⃣ 온도 표시
4️⃣ 아이콘 표시
간략하게 짜서 적을게 없다..