My index.js file get method
app.get('/getdata', function(req, res){
var resultArray = [];
mongo.connect(url, function(err, db){
assert.equal(null, err);
var cursor = db.collection('satyamsoft').find();
cursor.forEach(function(doc, err){
assert.equal(null, err);
resultArray.push(doc);
console.log(resultArray);
});
});
res.render('pages/getdata', {holedata: resultArray});
});
My getdata.ejs file
<h2> Family Details </h2>
<ul>
<% holedata.forEach(function(data) { %>
<li><<%= data.name %> - <%= data.title %> - <%= data.age %></li>
<% }); %>
</ul>
After executing the get method in the console showing data which is fetch from mongodbColnose data
But in the web page showing empty enter image description here
Am i doing anything wrong. Please help me. Advance thanks.
via Satyam
No comments:
Post a Comment