I am new to es6 classes and I want to know what can be the solution to my problem. Below is the code:-
class userscomp {
registerUser(userJoinData) {
var usersModelsData = new usersModel({
// Users Model
})
usersModelsData.save(function (err, userSavedData, numAffected) {
if (err)
throw err
else if(numAffected === 1 && !err) {
var authModelsData = new authsModel({
// Auth Model
})
authModelsData.save(function(err, authSavedData, numAffected) {
if (err)
throw err
else if(!err)
return true // Return from the registerUser function
})
}
})
}
}
In the above case my return doesn't work. Is there a way to return within the nested scope. Any help is greatly appreciated