Lab 07 Kaylyn#10
Open
kaylynyuh wants to merge 5 commits intocodefellows-seattle-javascript-401d10:masterfrom
Open
Lab 07 Kaylyn#10kaylynyuh wants to merge 5 commits intocodefellows-seattle-javascript-401d10:masterfrom
kaylynyuh wants to merge 5 commits intocodefellows-seattle-javascript-401d10:masterfrom
Conversation
bnates
reviewed
Sep 21, 2016
| req.on('end', function() { | ||
| try { | ||
| req.body = JSON.parse(req.body); | ||
| callback(null, req.body); |
There was a problem hiding this comment.
@kaylynyuh great callback pattern - conforms to industry standards
| parseBody(req, function(err) { | ||
| if (err) return console.error(err); | ||
| if(req.body.text){ | ||
| res.writeHead(200,{'Content-Type': 'text/plain'}); |
There was a problem hiding this comment.
@kaylynyuh best practice is to break this statement onto multiple lines - for example:
res.writeHead(200, {
'Content-Type': 'text/plain'
});
| res.end(); | ||
| } else { | ||
| res.writeHead(400); | ||
| res.write(cowsay.say({text: 'bad request\ntry: localhost:3000/cowsay?text=howdy'})); |
There was a problem hiding this comment.
@kaylynyuh great UX addition by alerting the user of the proper url structure
| res.writeHead(200); | ||
| res.write(cowsay.say({text: req.url.query.text})); | ||
| res.end(); | ||
| } else if (req.method === 'GET' && req.url.pathname === '/cowsay' && !req.url.query.text) { |
There was a problem hiding this comment.
@kaylynyuh this can be refactored into a series of if statements and without the inclusion of else or else if statements - we'll talk about this more in the coming days but try using return instead of explicit else or else if statements on your next major piece of functionality that you build
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.
No description provided.