mongodb - Node.js with mongo - Rendering "object" instead the data inside the template? -



mongodb - Node.js with mongo - Rendering "object" instead the data inside the template? -

check code...

var swig = require('swig'); var config = require('../config.json'); var mongojs = require('mongojs'); var objectid = mongojs.objectid; var db = require('mongojs').connect(config.mongodb, config.mongodbcollections); var roles; db.lists.find({type:'roles'}).toarray(function(err, item) { roles = item[0].data; console.log(roles); }); var sharetpl = swig.compilefile(__dirname +'/../html/register.html'); exports.index = function(req, res){ var output = sharetpl({ 'title': 'roles itself', 'roles' : [roles] }); res.send(output);

};

this console.log output...

[ { name: 'web developer', code: 'wdv' }, { name: 'web designer', code: 'wds' }, { name: 'system archtect', code: 'sar' } ]

it's okay, far...but html...

server side: <|-- {{roles}} -->

client html : <|-- [object object],[object object],[object object] -->

so, i'm stucked on it...it's rendering "[object object]" on client side instead info :( pretty frustrated. clue ? ty !

roles array of objects, need refer specific fields of each individual object in array.

if using mustache syntax follows:

{{#roles}} {{name}}, {{code}} {{/roles}}

node.js mongodb

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -