JSFiddle - React, Tailwind, and code Playground
HTML
<div class="panel-body">
<div class="text-center">
<button type="button" class="btn btn-info" onclick="loadTemp()">Temperatura</button>
</div>
<div class="panel-footer">
<p class="text-center" id="temp">---</p>
</div>
</div>
JavaScript
function loadTemp() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
temp.innerHTML = xhttp.responseText + ' ºC';
}
};
xhttp.open("GET", "https://thingspeak.com/channels/116346/field/1/last.html", true);
xhttp.send();
return loadTemp;
}
var temp = document.getElementById("temp");
setInterval(loadTemp(), 5 * 60 * 1000);