aboutsummaryrefslogtreecommitdiffstats
path: root/app/static/block_weather.js
blob: 4ae6d2d4b5e281be441134201a715f49116772ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
export function updateWeather() {
  const city = document.getElementById("city").value;
  fetch(`/weather?city=${encodeURIComponent(city)}`)
    .then(res => res.json())
    .then(data => {
      if (!data) {
        document.getElementById("weather-summary").innerText = `Error, "${city}" city not found`;
        return
      }
        document.getElementById("weather-summary").innerText = data.summary;
        document.getElementById("weather-icon").src = data.icon_url;
    });
}