How to add & remove items from Shopping Cart- Add to Cart - Remove From Cart - Node JS, Express js , Java Script
Suppose we have 3 Birthday Cakes in our database as a product - and we want to get item added & removed by customer - Before adding into cart we have to show Products(cakes) to customer using following code - Note - Create Your Own Roues, Controller & Models and Import it here //UserRouter.js //Middleware to get cake list to send on menu.ejs var Bcakes ; router . use ( "/menu" ,( req , res , next ) => { IndexController . fetchProducts ({ "catnm" : "birthday cake" }). then (( result ) => { Bcakes = result ; next (); }). catch (( err ) => { console . log ( err ); }); }) router . use ( "/" ,( req , res , next ) => { IndexController . fetchProducts ({ "catnm" : "birthday cake" }). then (( result ) => { Bcakes = result ; next (); }). catch (( err ) => { console . log ( err ); }); }) //============Middle Ware end =============...