const _sodium = require('libsodium-wrappers');
(async (model = this._modelUser) => { //Had to pass this._modelUser otherwise it'd be undefined
await _sodium.ready;
const sodium = _sodium;
let password = sodium.crypto_pwhash_str(Utils.urldecode(data.password), 7, 677445);
model.password = password;
console.log('In:' + model.password); //Good value
})();
console.log('Out:' + this._modelUser.password); //Undefined
So in this case, this._modelUser.password
is undefined outside function. I'd like to wait for this._modelUser
to get the right password value before continuing.
Does anyone have an idea about how to fix this ? Thanks for your help
Different than How do I return the response from an asynchronous call? because of the syntax (async => ()) and because of usage of a specific module: https://www.npmjs.com/package/libsodium