Groups
Groups
Sign in
Groups
Groups
Express
Conversations
About
Send feedback
Help
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 AM
11/5/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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 AM
11/5/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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 PM
11/5/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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