Hi I'm new in node js I'm using node version 7.10 to make apis
My controller
class SomeControllerClass {
async someFunction(req, req){
var afterDBAction = await DbHelper.SomeOtherFunction(req.body)
// afterDBAction is comming out undefined
}
}
I'm seperating DbHelper to make Controller thin and clean and all business logic is to be written at DbHelper.
User is the schema and its saving data in db but I dont't know why I'm getting undefined in my controller
class DbHelper {
SomeOtherFunction(userinfo){
var user = new User(userinfo);
bcrypt.hash(userinfo.password, saltRounds).then(function(hash, err) {
user.password = hash;
return user.save().then(function() {
if (err)
return err;
return user;
})
});
}
}