I am learning expressjs,mongodb using nunjucks template.An array is sent from server to html in the following way:
poll.find().sort({'date': -1}).toArray(function(err,docs){
res.render("home",{polls:docs});
});
The variable polls is an array of objects.I am able to access the polls array successfully in the html view but I don't know a way to access it in the client side js file to draw charts using the data inside array.
If I use <input type='hidden value='{{ polls }}'>
, it is converted to a string and the array, objects inside it cannot be accessed in client js. What can be done?