added sort

This commit is contained in:
Steve Waterworth
2018-01-30 16:22:57 +00:00
parent 152c4ab6ba
commit bc75e8d96b

View File

@@ -72,7 +72,7 @@ app.get('/product/:sku', (req, res) => {
// products in a category
app.get('/products/:cat', (req, res) => {
if(mongoConnected) {
collection.find({ categories: req.params.cat}).toArray().then((products) => {
collection.find({ categories: req.params.cat }).sort({ name: 1 }).toArray().then((products) => {
res.json(products);
}).catch((e) => {
console.log('ERROR', e);