Skip to content

Commit 82329b6

Browse files
lazlojulyevanlucas
authored andcommitted
doc: fix variable scoping bug in server example code
Const is block scoped. PR-URL: #8124 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
1 parent d7ab1ba commit 82329b6

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

doc/api/stream.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,14 @@ const server = http.createServer( (req, res) => {
130130
req.on('end', () => {
131131
try {
132132
const data = JSON.parse(body);
133+
// write back something interesting to the user:
134+
res.write(typeof data);
135+
res.end();
133136
} catch (er) {
134137
// uh oh! bad json!
135138
res.statusCode = 400;
136139
return res.end(`error: ${er.message}`);
137140
}
138-
139-
// write back something interesting to the user:
140-
res.write(typeof data);
141-
res.end();
142141
});
143142
});
144143

0 commit comments

Comments
 (0)