-
Couldn't load subscription status.
- Fork 9
Remove unused variables #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
4adbb6d
bc35b06
a11de8b
2572299
fec0b5d
30ec1f9
83f75d0
f3a6c10
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,9 +6,7 @@ var fs = require('fs'); | |
| var Cart = require('../models/cart'); | ||
| var products = JSON.parse(fs.readFileSync('./data/products.json', 'utf8')); | ||
|
|
||
| router.get('/', function (req, res, next) { | ||
| var productId = products && products[0].id; | ||
|
|
||
| router.get('/', function (_req, res, _next) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good work! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bold italics There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. abc There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ctrl + enter to submit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| res.render('index', | ||
| { | ||
| title: 'NodeJS Shopping Cart', | ||
|
|
@@ -17,20 +15,20 @@ router.get('/', function (req, res, next) { | |
| ); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| }); | ||
|
|
||
| router.get('/add/:id', function(req, res, next) { | ||
| router.get('/add/:id', function(req, res, _next) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. id? |
||
|
|
||
| var productId = req.params.id; | ||
| var cart = new Cart(req.session.cart ? req.session.cart : {}); | ||
| var product = products.filter(function(item) { | ||
| return item.id == productId; | ||
| return item.id === productId; | ||
| }); | ||
| cart.add(product[0], productId); | ||
| req.session.cart = cart; | ||
| res.redirect('/'); | ||
| inline(); | ||
| }); | ||
|
|
||
| router.get('/cart', function(req, res, next) { | ||
| router.get('/cart', function(req, res, _next) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cart? |
||
| if (!req.session.cart) { | ||
| return res.render('cart', { | ||
| products: null | ||
|
|
@@ -44,7 +42,7 @@ router.get('/cart', function(req, res, next) { | |
| }); | ||
| }); | ||
|
|
||
| router.get('/remove/:id', function(req, res, next) { | ||
| router.get('/remove/:id', function(req, res, _next) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or |
||
| var productId = req.params.id; | ||
| var cart = new Cart(req.session.cart ? req.session.cart : {}); | ||
|
|
||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0px
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
start my review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
third
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6