D
D
deemaagog2017-10-09 13:55:23
Node.js
deemaagog, 2017-10-09 13:55:23

Node.js (express) methods disappear when saving class instances in req.session, why?

var Cart = function() {
this. sum = 1;
this.add = function(){ this.sum++; };
}
req.session.cart = new Cart();
on repeated calls, sum is present, but add is not. How can you save an object with methods?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question