Hello,
I am making a weather app.
Is there better way to select all needed data like temperature, sunsetTime etc. and manipulate the DOM? Do I need to write something like this 50 times?
let weatherData= document.querySelector("#weatherData").textContent = data.weatherData;
more code below
fetch("https://cors-anywhere.herokuapp.com/" + urlAPI)
.then(res => {
return res.json();
})
.then(data => {
console.log(data);
const { temperature, summary, icon } = data.currently;
const temp = Number(temperature.toFixed(1));
let hourlySummary = document.querySelector("#hourlySummary").textContent = data.hourly.summary;
let currentTemp = document.querySelector(".temperatureInC").textContent = temp;
let shortSummary = document.querySelector(".summary").textContent = summary;
let weekSummary = document.querySelector("#weekSummary").textContent = data.daily.summary;
setIcon(icon, document.querySelector("#icon1"));
});