-
Notifications
You must be signed in to change notification settings - Fork 12
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
Jake #1
base: master
Are you sure you want to change the base?
Jake #1
Conversation
server.js
Outdated
|
||
if(req.method === 'GET' && req.url.pathname === '/') { | ||
let params = req.url.query; | ||
res.write(cowsay.say(200, {text: 'Hello from my server!'})); |
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.
cowsay doesn't want a status code.
server.js
Outdated
res.write(cowsay.say({text: req.body.text})); | ||
} else { | ||
res.statusCode = 400; | ||
res.write(400, cowsay.say({text: 'bad request'})); |
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.
Also here this will cause an error.
server.js
Outdated
res.end(); | ||
} | ||
|
||
res.end(); |
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.
this in some cases will cause write after end error. It can be good to either handle them all at the end or to handle them all at each path not both.
No description provided.