How to assign all values of the object from the argument?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
14 views
The function expects a object

req.session.login({ _id: checkUser._id, role: checkUser.role })


Then, the whole object preuniverse variable

session.Session.prototype.login = function(user, cb) { req.session.regenerate((err) => { req.session.userData = user }) }


The result is

req.session.userData = { _id: checkUser._id, role: checkUser.role }


How to make an assignment not of the entire object, and the destructurization tipo

req.session._id = checkUser._id req.session.role = checkUser.role


While leaving the function call is unchanged

req.session.login()

Object.assign is not suitable, because it will return a new object, I can't change the session. In addition, it will erase the current value.
by | 14 views

1 Answer

0 like 0 dislike
by

Related questions

110,608 questions
257,187 answers
0 comments
40,253 users