var signupHelper = require('./util/signuphelper');
router.post('/signup', signupHelper.checkEmpty, signupHelper.test, function(req,res){ });
I'm new to node.js (don't know if it is called callback.). My problem is, when signupHelper.checkEmpty has no errors it doesn't return anything, so it cannot proceed to .test. How can i fix this? Cos if there's no error, I want to check the data if it doesn't exist in the db so I need to call signupHelper.test to check.
In my checkEmpty
exports.checkEmpty = function(req,res){
------- some code here -------
if(errors.length > 0){
req.flash('errors', errors);
res.redirect('/signup');
}
}
exports.test = function(req,res) { some code....}
signupHelper.test. But it's not working. The browser keeps loading. But when it encounters error (the if statement is true) then the browser redirects (as expected).