diff --git a/doc/api/stream.md b/doc/api/stream.md index 16644f8e2257c8..72baca9c4ab050 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(); }); });