Skip to content

Shahab-exercise-express#13

Open
Shahab13 wants to merge 1 commit intopce-uw-jscript400:masterfrom
Shahab13:master
Open

Shahab-exercise-express#13
Shahab13 wants to merge 1 commit intopce-uw-jscript400:masterfrom
Shahab13:master

Conversation

@Shahab13
Copy link

No description provided.

Copy link
Contributor

@bwreid bwreid left a comment

Choose a reason for hiding this comment

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

Great job! For the most part, everything seems to be working as intended but there are some code quality issues and an error that is surfacing. Please take a look at my comments for more details.

const id = req.params.id;
let vegetable = vegetables.find(veggie => veggie.id === id);

console.log(id);
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove console.log() statements before committing!

console.log(name);

myList = vegetables.filter(veggie =>
veggie.name.includes(name.substring(1, req.query.name.length - 1))
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting. I assume this was to get around the quotations. This will work but also return possibly more results than expected.

}
vegetable.name = name;
vegetable.price = price;
res.status(201).json(vegetable);
Copy link
Contributor

Choose a reason for hiding this comment

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

Per the instructions, this should be a 200.

next({ status: 404, message });
}
let filtered = fruits.filter(
(x = (value, index, arr) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this x = bit?

const message = `PUT: Could not find ${name} with ID of ${id}`;
next({ status: 404, message });
}
vegetable.name = name;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm getting an error here of TypeError: Cannot set property 'name' of undefined. My guess is you need to return here to stop the rest of the function from executing.

//console.log(data.vegetables);
//console.log("===========================");
data.fruits = filtered;
//console.log(data.vegetables);
Copy link
Contributor

Choose a reason for hiding this comment

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

These kind of statements should be removed as well.

@Shahab13
Copy link
Author

Shahab13 commented Jul 15, 2019 via email

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