diff --git a/ui/election.html b/ui/election.html index a6b10f4..67026b0 100644 --- a/ui/election.html +++ b/ui/election.html @@ -108,12 +108,14 @@ headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload), }); - if (!response.ok) throw new Error("Failed to submit vote."); + if (!response.ok) { + res = await response.json(); + throw new Error(res.message); + } this.message = "Vote submitted successfully!"; this.success = true; } catch (error) { - console.error(error); - this.message = "Failed to submit vote."; + this.message = error.message; this.success = false; } }