Tuesday, 15 February 2011

node.js - Does linkedin's dustJS works with mongoosejs object? -



node.js - Does linkedin's dustJS works with mongoosejs object? -

i've followed passportjs illustration in krakenjs. https://github.com/krakenjs/kraken-examples/blob/master/with.passport/lib/auth.js#l104

here's code snippets taken example.

exports.injectuser = function() { homecoming function injectuser(req, res, next) { if (req.isauthenticated()) { res.locals.user = req.user; } next(); }; };

when tried {user}, outputs fields in user object, when {user.fullname}, outputs blank.

if alter code below,

exports.injectuser = function() { homecoming function injectuser(req, res, next) { if (req.isauthenticated()) { res.locals.user = json.parse(json.stringify(req.user)); } next(); }; };

it works fine when do, {user.fullname}. thought why dustjs can't parse mongoose object?

i tried check what's instance type of object, , said [object object]. wont work unless explicitly json.stringify , json.parse it.

any recommended solution or explanation why happening?

found solution. it's issue dustjs-linkedin library. using 2.4.0. when alter 2.3.4, works. hope helps others.

node.js express mongoose dust.js kraken.js

No comments:

Post a Comment