-
-
Notifications
You must be signed in to change notification settings - Fork 512
London-10-shadi-fakhri-node-week-1 #329
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.
Well done, Shadi!
First, thank you for putting the "node_modules" in the gitignore file. You did everything correctly. I will now add some error handling for you, which will be useful in the future.
|
||
//...END OF YOUR CODE | ||
// /quotes - Should return all quotes (json) | ||
app.get("/quotes", (req, res) => { |
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.
app.get("/quotes", (req, res) => {
if (quotes.length === 0) {
return res.status(404).json({ error: "No quotes found." });
}
res.send({ quotes });
});
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.
thanks, Shayan. you mentioned a good point. From now I will use it in my projects.
app.get("/quotes", (req, res) => { | ||
res.send({quotes}); | ||
}); | ||
// /quotes/random - Should return ONE quote (json) |
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.
app.get("/quotes/random", (req, res) => {
if (quotes.length === 0) {
return res.status(404).json({ error: "No quotes found." });
}
const randomQuote = pickFromArray(quotes);
res.send(randomQuote);
});
Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in
HOW_TO_MARK.md
in the root of this repositoryYour Details
Homework Details
Notes
What did you find easy?
What did you find hard?
What do you still not understand?
Any other notes?