Skip to content

Commit

Permalink
doc: fix variable scoping bug in server example code
Browse files Browse the repository at this point in the history
Const is block scoped.

PR-URL: #8124
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Myles Borins <[email protected]>
  • Loading branch information
lazlojuly authored and MylesBorins committed Oct 26, 2016
1 parent c235708 commit 3a3fde6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,15 @@ var server = http.createServer( (req, res) => {
// the end event tells you that you have entire body
req.on('end', () => {
try {
var data = JSON.parse(body);
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 3a3fde6

Please sign in to comment.