Skip to content

Commit 3a3fde6

Browse files
lazlojulyMylesBorins
authored andcommitted
doc: fix variable scoping bug in server example code
Const is block scoped. PR-URL: #8124 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Myles Borins <[email protected]>
1 parent c235708 commit 3a3fde6

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

doc/api/stream.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,15 @@ var server = http.createServer( (req, res) => {
6767
// the end event tells you that you have entire body
6868
req.on('end', () => {
6969
try {
70-
var data = JSON.parse(body);
70+
const data = JSON.parse(body);
71+
// write back something interesting to the user:
72+
res.write(typeof data);
73+
res.end();
7174
} catch (er) {
7275
// uh oh! bad json!
7376
res.statusCode = 400;
7477
return res.end(`error: ${er.message}`);
7578
}
76-
77-
// write back something interesting to the user:
78-
res.write(typeof data);
79-
res.end();
8079
});
8180
});
8281

0 commit comments

Comments
 (0)