I am trying to store the hash password and checking the it is valid or not.
var bcrypt = require('bcrypt');
let data = "";
bcrypt.genSalt(10, function(err, salt) {
    bcrypt.hash("my password", salt, function(err, hash) {
        // Store hash in your password DB.
        console.log(hash);
        data = hash;
    });
});
bcrypt.compare("my password", data, function(err, res) {
    // res === true
    console.log(res)
});
return value always false.?
but if I move the compare inside genSalt function its returning true.
Thanks
 
    