London 10 - Elena Barker - Node Module - Quote-Server - Week 1#321
London 10 - Elena Barker - Node Module - Quote-Server - Week 1#321ElenaBarker wants to merge 4 commits intoCodeYourFuture:masterfrom
Conversation
giorgiguts
left a comment
There was a problem hiding this comment.
Excellent work! I think you will find a couple of comments which I've added quite useful.
|
|
||
| app.get("/quotes/search", function (request, response) { | ||
| const term = request.query.term; | ||
| if (!term) { |
There was a problem hiding this comment.
excellent use of negation! 🥳 Instead of writing unnecessary expressions such as if(term === undefined) with negation, we as devs can really shorten the if expressions and make it really understandable for other devs looking at it!
server.js
Outdated
|
|
||
| //START OF YOUR CODE... | ||
| app.get("/quotes", function (request, response) { | ||
| response.json(quotes); |
There was a problem hiding this comment.
Excellent work! As an extra layer of security and with the idea of minimising the amount of bugs in our backend and in our codebase in general, we can always think of adding an extra layer of protection.
For instance, whenever you send a response, it's generally a good idea to add a check that our response came back with a code 200, which means that the request is successful (you can read more on http status codes here).
If you are using express.js v4 and higher, you can simply add this line:
response.status(200).json(quotes);
This will check that if the response is 200, only after it will send the quotes json 😊
Otherwise, overall, excellent work!
There was a problem hiding this comment.
Thank you so much for the review, Giorgi. I truly appreciate your valuable feedback, and I have integrated your recommendations to improve my code.
There was a problem hiding this comment.
Hi Elena, it's my pleasure and I'm glad if you found my small recommendation useful! 😊 keep up the great work!
Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in
HOW_TO_MARK.mdin 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?