J.Sorge HW2 - Express#26
Open
Jiansorge wants to merge 3 commits into
Open
Conversation
bwreid
reviewed
Aug 10, 2019
Contributor
bwreid
left a comment
There was a problem hiding this comment.
Well done! Just a few comments for you.
| } | ||
| return result; | ||
| }; | ||
| } |
Contributor
There was a problem hiding this comment.
Both of these should not be necessary. Were you having issues calling either of these functions?
| const { vegetables } = data | ||
| const { id } = req.params | ||
|
|
||
| const veg = vegetables.filter(el => el.id.includes(id))[0] |
Contributor
There was a problem hiding this comment.
.find() is a good substitute here.
| const veg = vegetables.filter(el => el.id.includes(id))[0] | ||
| if (!veg) { | ||
| const message = `Could not find vegetable with ID of ${id}` | ||
| next({ status: 404, message }) |
Contributor
There was a problem hiding this comment.
You'll want to add a return statement here as well, otherwise the next few lines will also get executed.
| res.status(200).json(veg) | ||
| }) | ||
|
|
||
| app.put('/vegetables/:id', helpers.validate, (req, res, next) => { |
Contributor
There was a problem hiding this comment.
I think helpers.validate should perform the same function as the lines you have below.
| const { id } = req.params | ||
|
|
||
| const fruit = fruits.filter(el => el.id.includes(id))[0] | ||
| console.log(fruit) |
Contributor
There was a problem hiding this comment.
Please remove console.log() statements before committing!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Complete.
Curious on best method to approach IE with ES6 Array.prototype.filter(), .findIndex(), etc.