diff --git a/api/virtualLottery.js b/api/virtualLottery.js index e9ec85f..74224d6 100644 --- a/api/virtualLottery.js +++ b/api/virtualLottery.js @@ -187,7 +187,10 @@ const drawWinner = async (req, res) => { ); await newWinnerElement.save(); - return res.json(winner); + return res.json({ + success: true, + winner + }); }; const finish = async (req, res) => { diff --git a/src/components/VirtualLotteryRegistrationPage.vue b/src/components/VirtualLotteryRegistrationPage.vue index 153c6e9..24145a1 100644 --- a/src/components/VirtualLotteryRegistrationPage.vue +++ b/src/components/VirtualLotteryRegistrationPage.vue @@ -229,7 +229,8 @@ export default { this.drawingWinner = true; let response = await getVirtualWinner(); - if (response) { + if (response.success) { + console.log("Winner:", response.winner); if (this.currentWinners < this.numberOfWinners) { this.countdown(); } else { @@ -245,7 +246,7 @@ export default { this.getAttendees(); } else { this.drawingWinner = false; - alert("Noe gikk galt under trekningen..!"); + alert("Noe gikk galt under trekningen..! " + response["message"]); } } },