mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
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>
This commit is contained in:
1 parent
e1c042e2dc
commit
66d697cb5c
1 file changed
+3
-4
+3
-4
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user