Skip to content

Commit 061880f

Browse files
committed
doc: fix variable scoping bug in Stream HTTP server example code
Const is block scoped.
1 parent 6478260 commit 061880f

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)