Skip to content

Commit

Permalink
doc: fix variable scoping bug in Stream HTTP server example code
Browse files Browse the repository at this point in the history
Const is block scoped.
  • Loading branch information
lazlojuly committed Aug 16, 2016
1 parent 6478260 commit 061880f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,14 @@ const server = http.createServer( (req, res) => {
req.on('end', () => {
try {
const data = JSON.parse(body);
// write back something interesting to the user:
res.write(typeof data);
res.end();
} catch (er) {
// uh oh! bad json!
res.statusCode = 400;
return res.end(`error: ${er.message}`);
}

// write back something interesting to the user:
res.write(typeof data);
res.end();
});
});

Expand Down

0 comments on commit 061880f

Please sign in to comment.