Skip to content

Sunglasses.io#182

Open
cjedrasik03 wants to merge 4 commits intoprojectshft:masterfrom
cjedrasik03:master
Open

Sunglasses.io#182
cjedrasik03 wants to merge 4 commits intoprojectshft:masterfrom
cjedrasik03:master

Conversation

@cjedrasik03
Copy link

No description provided.

const products = require('../initial-data/products.json');

app.get('/api/products', (req, res) => {
res.status(200).json(products);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check your code alignment

});

app.get('/api/products/:id', (req, res) => {
const product = products.find(p => p.id === req.params.id);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to be cheap, keep it readable

Suggested change
const product = products.find(p => p.id === req.params.id);
const product = products.find(product => product.id === req.params.id);

});

app.get('/api/users', (req, res) => {
res.status(200).json(users);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alignment

});

app.get('/api/users/:username', (req, res) => {
const user = users.find(u => u.login.username === req.params.username);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user, don't use u


// add item to a users cart
app.post('/api/users/:username/cart', (req, res) => {
const user = users.find(u => u.login.username === req.params.username);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dry, anything you can do to reuse?

}

// If match found, return a success message (no token for now)
res.status(200).json({ message: 'Login successful' });

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not really authenticating, you need to return a token that then is sent on every call and every relevant api needs to check it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants