Skip to content

Instantly share code, notes, and snippets.

@HendrikHaase
Created July 25, 2014 17:11
Show Gist options
  • Select an option

  • Save HendrikHaase/d08cac40bacd55b3ab4b to your computer and use it in GitHub Desktop.

Select an option

Save HendrikHaase/d08cac40bacd55b3ab4b to your computer and use it in GitHub Desktop.
app.post('/api/query', function (req, res) {
if (req.body.query) {
async.waterfall([
function (next) {
var query=req.body.query;
console.log(query);
connection.query(query, next);
},
function (rows, fields, next) {
next(null,rows);
}
], function (error, result) {
if (error) {
res.send(403, error.toString());
} else {
res.json(result);
}
});
} else {
res.send(500, "Internal Server Error");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment