Skip to content

Instantly share code, notes, and snippets.

@ZachMoreno
Created January 22, 2015 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZachMoreno/8ea621015c8fc7502520 to your computer and use it in GitHub Desktop.
Save ZachMoreno/8ea621015c8fc7502520 to your computer and use it in GitHub Desktop.
router.route('/api/categories/:categoryID')
.get(function(req, res) {
// query
connection.query('SELECT listers.lister_id, listers.listing_name, listers.city, listing_categories.category_name FROM listing_categories INNER JOIN listings ON listing_categories.listing_category_id = listings.listing_category_id JOIN listers ON listings.lister_id = listers.lister_id WHERE listings.listing_category_id = ' + req.param('categoryID'), function(err, rows, fields) {
if(err) {
res.send(err);
console.log(err);
connection.end();
} else {
res.send(rows);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment