Skip to content

Comments

Jake#1

Open
Loaye wants to merge 16 commits intocodefellows-javascript-401d17:masterfrom
Loaye:jake
Open

Jake#1
Loaye wants to merge 16 commits intocodefellows-javascript-401d17:masterfrom
Loaye:jake

Conversation

@Loaye
Copy link

@Loaye Loaye commented Jul 26, 2017

No description provided.

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!'}));
Copy link

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'}));
Copy link

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();
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants