function update() { fetch('http://localhost:9050/api/ais') .then(function (response) { return response.json(); }) .then(function (data) { updateData(data); }) .catch(function (err) { console.log('error: ' + err); }); function updateData(data) { var table = document.getElementById("aisTable"); const table = document.getElementById('Table'); let numItems = 1; numItems++; const row = document.createElement('tr'); row.innerHTML = ` `; // You could also do the same for the cells and inputs table.appendChild(row); for (var i = 0; i < data.length; i++) { var div = document.createElement("div"); div.innerHTML = 'Name: ' + data[i].Name; mainContainer.appendChild(div); } } } function startup() { setInterval(function () { update(); }, 10000); }