-
-
Notifications
You must be signed in to change notification settings - Fork 342
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
London Class 9 - Farzaneh Haghani - Node - Class work #19
base: master
Are you sure you want to change the base?
Conversation
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.
Some minor error handling changes, but overall really nice work!!
const amount = req.query.amount; | ||
res.status(200).json(`You asked for ${amount} chocolate!`); |
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.
How would you handle the case where amount
wasn't passed in as a query param?
albums.forEach((album, index) => { | ||
if (album.albumId === req.params.id) { | ||
albums.splice(index, 1); | ||
res.status(200).json("Deleted"); | ||
} |
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.
Could add an else case here which returns a 404
status
}) | ||
}); | ||
|
||
app.listen(3000, () => { |
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.
Usually we'd define the port as an environment variable and give it a default value, e.g. const PORT = process.env.PORT ?? 3000
, app.listen(PORT, ...)
- this makes it easier to deploy when you come around to doing that
No description provided.