summaryrefslogtreecommitdiff
path: root/doc/api
diff options
context:
space:
mode:
authorlazlojuly <lazlo.gy@gmail.com>2016-08-16 17:56:52 +0100
committerEvan Lucas <evanlucas@me.com>2016-08-24 07:50:42 -0500
commit82329b6e8fe3fd364e13869cc3387eb4e68a7ecc (patch)
tree7bf08b760b70c8d3aedf26d5604618f84a33cb3d /doc/api
parentd7ab1baed2423b3827ddf90846ed6b602673b38b (diff)
downloadnode-new-82329b6e8fe3fd364e13869cc3387eb4e68a7ecc.tar.gz
doc: fix variable scoping bug in server example code
Const is block scoped. PR-URL: https://github.com/nodejs/node/pull/8124 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'doc/api')
-rw-r--r--doc/api/stream.md7
1 files changed, 3 insertions, 4 deletions
diff --git a/doc/api/stream.md b/doc/api/stream.md
index 16644f8e22..72baca9c4a 100644
--- a/doc/api/stream.md
+++ b/doc/api/stream.md
@@ -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();
});
});