return res.send() good or bad style ?

763 views
Skip to first unread message

Jérémy Lal

unread,
Nov 5, 2012, 8:43:57 AM11/5/12
to expre...@googlegroups.com
Hi,

Is it a good habit to do "return res.send(200)"
instead of simply "res.send(200)" ?

that question is slowly killing me :)

Jérémy.

greelgorke

unread,
Nov 5, 2012, 10:09:31 AM11/5/12
to expre...@googlegroups.com, hol...@gmail.com
i guess it doesn't matter  since the router/middleware do not care about return values.

tjholowaychuk

unread,
Nov 5, 2012, 12:05:17 PM11/5/12
to Express
the return doesn't do anything it's just to short-circuit the
statement. the following are equivalent in that sense,
but one has less nesting:

if (err) return next(err);
res.send(200);

if (err) {
next(err);
} else {
res.send(200);
Reply all
Reply to author
Forward
0 new messages