The async function for getting episodes now send response when the async function is done.

This commit is contained in:
Kevin Midboe
2017-04-06 17:42:28 +02:00
parent 97e062ef13
commit f3ef2ef15a

View File

@@ -31,18 +31,18 @@ router.get('/seasoned', function(req, res) {
var db = new sqlite3.Database(db_path);
var returnMsg;
var id = req.param('id');
db.serialize(function() {
db.get("SELECT * FROM stray_eps WHERE id = '" + id + "'", function(err, row) {
returnMsg = row;
// res.json({message: row});
// returnList.push(row.original, row.full_path, row.last_name);
}), console.log(returnMsg);
}), console.log(returnMsg);
// console.log(returnMsg);
// db.close();
db.close();
res.json({message: toString(returnMsg)});
//console.log(returnMsg);
function getEpisode(id, fn){
db.serialize(function() {
db.get("SELECT * FROM stray_eps WHERE id = '" + id + "'", function(err, row) {
fn(row)
})
});
}
getEpisode(id, function(episode){
res.json({episode}); // this is where you get the return value
});
});
// more routes for our API will happen here