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 <jasnell@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
  • Loading branch information
lazlojuly authored and evanlucas committed Aug 24, 2016
1 parent d7ab1ba commit 82329b6
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 82329b6

Please sign in to comment.