Reputation: 1529
I'm not sure how to use NodeJS API in combination with express.io There is an API definition:
app.get('/api', function(req, res) {
connection.query("select * from table") , function (error, results) {
if(error) {
throw error;
}
else {
res.end(JSON.stringify(results));
}
});
});
How to transform API to use it with express.io?
I'm trying with app.io.route
, but it's obviously wrong:
app.io.route('/api', function(req) {
connection.query("select * from table", function (error, results) {
if(error) {
throw error;
}
else {
req.end(JSON.stringify(results));
}
});
});
Upvotes: 1
Views: 50