Ok so I am trying to use Node.js and SQLITE to read in values from SQLITE and send them to an html page using AJAX. I am having trouble creating a proper JSON object(to send with AJAX) out of the the values I am getting from SQLite. Could someone please let me know what the proper syntax is to do this?
Thanks!
Here is my code for the get method
app.get('/users/*', function(req,res){
var nameToLookup= req.params[0];
db.serialize(function() {
db.each("SELECT rowid AS id, name,job,pet FROM people_new", function(err, row) {
if(nameToLookup === row.name)
{
var e = JSON.stringify({'name':row.name,"job":row.job,"pet":row.pet});
res.send(e);
return;
}
});
});
res.send('{}');
}
);
Aucun commentaire:
Enregistrer un commentaire