Skip to content

Commit

Permalink
Fixed retry when connection errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mp-se committed Jun 1, 2023
1 parent 8b41a9a commit 8e80652
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@
var url = baseURL + "/api/config";

console.log("Fetching beer configuration");

$("#status").text("Fetching beer information");

$.getJSON(url, function (cfg) {
Expand Down Expand Up @@ -200,17 +199,18 @@
$("#beer-ebc2").text(cfg["beer-ebc2"]);

$("#status").text("Connected");
configLoaded = true;

}).fail(function () {
console.log("Failed to fetch data from /api/config");
$("#status").text("Not connected");
start();
});
}

function getStatus() {
if (!configLoaded) {
getConfig();
configLoaded = true;
}

var url = baseURL + "/api/status";
Expand Down Expand Up @@ -269,6 +269,7 @@
}).fail(function () {
console.log("Failed to fetch data from /app/status");
$("#status").text("Not connected");
start();
});
}

Expand All @@ -277,6 +278,7 @@
}

function start() {
clearInterval();
setInterval(getStatus, 5000);
}
</script>
Expand Down

0 comments on commit 8e80652

Please sign in to comment.