SHARE
TWEET

Untitled

a guest Jul 21st, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. router.get("/:id/:storename", (req, res) => {
  2.  
  3.     var storeId = req.params.id;
  4.     var storeName = req.params.storename;
  5.  
  6. // Check if cart exists on current session, else create empty cart
  7.     var cart = new Cart(req.session.cart ? req.session.cart : {});
  8.  
  9. // Check if the store exists in database
  10.     Seller.findOne({storeName: storeName}, (err, seller) => {
  11.     if(err){
  12.     console.log(err);
  13.     }else{
  14.  
  15. // get all product categories in database
  16.         Category.find({createdBy: seller.username}, (err, categories) => {
  17.     if(err){
  18.     console.log(err);
  19.     }else{
  20.  
  21. // get all products in database                     Product.find({createdBy: seller.username}, (err, products) => {
  22.     if(err){
  23.     console.log(err);
  24.     }else{
  25.     res.render("store.ejs", {seller: seller, categories: categories,          products: products, storeId: storeId, storeName: storeName});
  26.          }});
  27.        }});
  28.           }});
  29.     });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top