I am new to the node.js . I have created server side application by using node.js. In this application i am retrieving the data from the database . I have following code for this:
router.map(function () {
this.root.bind(function (req, res) {
db.all("SELECT * FROM employee", function(err, rows)
{
rows.forEach(function(row)
{
str=str+' '+row.name+' '+row.empid+' '+row.address+' '+row.mobile;
res.send(str);
});
});
});
this code returning me only the first row of the database as control returns after res.send(str). I want data in my iOS app in json format. Please suggest some solution on this problem.
Something like
OR
Should work fine, depending on whether the “rows” object is simple or not.