रेंडर में, आप परामर्श किए गए डेटा के साथ JSON वैरिएबल वापस कर सकते हैं और दृश्य में दिखा सकते हैं। res.render इस तरह अंतिम निर्देश हो सकता है। कुछ इस तरह:
var obj = {};
router.get('/data', function(req, res){
connection.query('SELECT * FROM users', function(err, result) {
if(err){
throw err;
} else {
obj = {print: result};
res.render('print', obj);
}
});
});
<body>
<table id="table" >
<thead>
<tr>
<th>Username</th>
<th>Password</th>
</tr>
</thead>
<tbody>
<% print.forEach(function (user) { %>
<tr>
<td><%= user.username %></td>
<td><%= user.password %></td>
</tr>
<% }) %>
</tbody>
</table>
</body>
</html>