Shashika Shashika - 1 year ago 63
Node.js Question

Unhandled Rejection - passport login app node js

I'm creating

login app and using
js for authentication. I use a local mysql database and use
as ORM library.

In my user model, I have created to get the user by username.

module.exports.findUserByUsername = function(username, callback){
User.findOne({ where: {username: username} }).then(function(user) {
var userObj = user.get({plain:true});

In router file

passport.use('login', new LocalStrategy(
function (username, password, done) {

User.findUserByUsername(username, function (err, user) {
if(err) {
throw err;

I'm getting an error
Unhandled rejection (<{object_values...>, no stack trace)

How can I solve this issue?

Answer Source

You need to change callback calling like this :

callback(null, userObj);