I have an Express JS app that uses express-session for session management.
I am trying to save some values to session in controller A and consume them in controller B, and send them as context to a template like so:
controllerA: function(req, res, next) {
req.session.context = {
id: '123123123',
phone: '09998889999'
};
return res.redirect(res.locals.pathFor('verifications#phoneVerify'));
}
:
:
:
controllerB: function(req, res, next) {
//Some code here
return res.render('templatepath/template', req.session.context);
}
The problem is, that when I do this, I get an error at the template render step saying:
TypeError: Converting circular structure to JSON
If I instead do this as:
req.session.id: '123123123',
req.session.phone: '09998889999';
The code works just fine. Does express-session
have an issue with objects?