var Product = require(__dirname + "/../models/productModel");
var handleError = require(__dirname + "/../lib/handleError");
var bodyParser = require('body-parser');
var express = require('express');
var clientRouter = module.exports = exports = express.Router();
var urlencodedParser = bodyParser.urlencoded({extended: false});

clientRouter.get('/product', function(req, res) {
  Product.find({}, function(err, data) {
    if(err) handleError(err, res);
    res.json(data);
  });
});

clientRouter.get('/product', function(req, res) {
  $(document).ready(function() {
    $("button").click(function() {
      Product.findOne({name: userInput}, function(err, data) {
        if(err) handleError(err, res);
        res.json(data);
      });
    });
  });
});

clientRouter.post('/product', urlencodedParser, function(req, res) {
  var newProduct = new Product({
    name: req.body.productName,
    pricePerUnit: req.body.pricePerUnit,
    unit: req.body.unit,
    description: req.body.description
  });
  newProduct.save(function(err, data) {
    if(err) return handleError(err);
    res.json(data);
  });
<<<<<<< HEAD
  res.end(JSON.stringify(res));
});
=======
});
>>>>>>> 80218ed4d860a4c675bbb2462a61fc4984bb53fc

@@ -1103,114 +1103,8 @@
 %7D);%0A
-%3C%3C%3C%3C%3C%3C%3C HEAD%0A  res.end(JSON.stringify(res));%0A%7D);%0A=======%0A%7D);%0A%3E%3E%3E%3E%3E%3E%3E 80218ed4d860a4c675bbb2462a61fc4984bb53fc
+%7D);
 %0A

update file