function getRadioStats() { const $ = id => document.getElementById(id); fetch("/stats") .then(r => r.json()) .then(radio => { $("radio-status").innerHTML = `On-air since `; $("radio-song").textContent = radio.song; $("radio-listeners").textContent = radio.listeners; $("radio-listener-peak").textContent = radio.listener_peak; }).catch(() => { $("radio-status").textContent = "Now is offline"; $("radio-song").textContent = $("radio-listeners").textContent = $("radio-listener-peak").textContent = "n/a"; }); } getRadioStats(); setInterval(getRadioStats, 45000);