Always return success bool from getWinner endpoint

This commit is contained in:
2020-10-11 22:20:09 +02:00
committed by KevinMidboe
parent b3b5e87ab5
commit e76e814877
2 changed files with 7 additions and 3 deletions

View File

@@ -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) => {

View File

@@ -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"]);
}
}
},