It continues execution even if the condition is true and return res.json() is executed.
_.each(rooms, function(room){
if(room.users.length == users.length) {
return res.json(room); // <-- returns but still continuous execution
}
});
Below is the error printed in console.
error: Error: Cannot write to response more than once
Do I need to do anything else?