Skip to content

Commit

Permalink
Fix: separate assignment and condition check in Update index.js
Browse files Browse the repository at this point in the history
assignment was being done inside condition check leading to confusion in reading code.
  • Loading branch information
sazk07 authored Nov 12, 2024
1 parent c6f399c commit 00887b9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/params/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ app.param(['to', 'from'], function(req, res, next, num, name){
// Load user by id

app.param('user', function(req, res, next, id){
if (req.user === users[id]) {
req.user = users[id]
if (req.user) {
next();
} else {
next(createError(404, 'failed to find user'));
Expand Down

0 comments on commit 00887b9

Please sign in to comment.