diff --git a/templates/bet.html b/templates/bet.html
index f7e6f5a..e0adc36 100644
--- a/templates/bet.html
+++ b/templates/bet.html
@@ -35,15 +35,16 @@
async function getBet() {
let response = await fetch("/api/getCurrentBet");
- if (response.ok) {
- let data = await response.json();
+ let data = await response.json();
+ if (response.ok || data.error != null) {
document.getElementById("question").innerText = data.question;
outcomes = data.possible;
document.getElementById("possible").innerText = "Possible outcomes: " + outcomes.join(", ");
// noinspection ES6MissingAwait
updateTimer(data.timeToBet);
} else {
- document.getElementById("question").innerText = "No bet is currently active";
+ alert("There are no bets currently open");
+ window.location.href = "/";
}
}