fetch asks a server for data without reloading the page. async/await keeps the code readable.
async function showWeather() { const url = "https://api.open-meteo.com/v1/forecast?latitude=46.95&longitude=7.45¤t=temperature_2m"; const response = await fetch(url); const data = await response.json(); document.querySelector("#temp").textContent = data.current.temperature_2m + "°C"; } showWeather();