In Node with Express, I have a piece of code like this.
if (req.body.var1 >= req.body.var2){
res.json({success: false, message: "End time must be AFTER start time"});
console.log('Hi')
}
console.log('Hi2')
//other codes
I expected that if var1 is >= var2, the response would be sent and the execution would end. Like return statements in Java/C#
But appearantly that's not the case. After the response is sent, both 'Hi' and 'Hi2' and all the other code after that continues to get executed.
I was wondering how I would stop this from happening?
Also, I was wondering under what circumstances would you actually want code to keep on executing after a response has already been sent.
Cheers