title: Nodejs mysql is assigning empty value
body: <p>I am using nodejs and mysql and I have controller, route, and auth middleware for authenticating the user.</p>
  <p><strong>Route</strong></p>
  <pre><code>router.route(&quot;/profile&quot;).get(protect, getUserProfile);
  
  </code></pre>
  <p><strong>protect middle ware</strong></p>
  <pre><code>const protect = asyncHandler(async (req, res, next) =&gt; {
    let token;
    if (
      req.headers.authorization &amp;&amp;
      req.headers.authorization.startsWith(&quot;Bearer&quot;)
    ) {
      try {
        token = req.headers.authorization.split(&quot; &quot;)[1];
        const decoded = jwt.verify(token, process.env.JWT_SECRET);
        console.log(&quot;Decoded value&quot;);
        console.log(decoded);
        let sql =
          &quot;select @uid :=`user_id`, first_name, last_name, email from dasa_user as var, (SELECT @uid := NULL) init_var where email=?;select @finaluid:= `user_id` from user_type, (SELECT @finaluid := NULL) init_var  where user_id =@uid AND type='customer';select customer_id from customer where user_id =@finaluid;&quot;;
        db.query(sql, [decoded.id], (err, result) =&gt; {
          if (result) {
            req.user = result;
          } else {
            res.status(404);
            res.json(err);
          }
        });
  
        next();
      } catch (error) {
        console.error(error);
        res.status(401);
        throw new Error(&quot;Not authorized, token failed&quot;);
      }
    }
    if (!token) {
      res.status(401);
      throw new Error(&quot;Not authorized, no token&quot;);
    }
    next();
  });
  </code></pre>
  <br>
  Here I am passing the value of `result` to the `req.user` but it gets assigned empty value.
  When I try to access `req.user` value from controller like this,<br> But result do have a value. 
  <p><strong>controller</strong></p>
  <pre><code>const getUserProfile = asyncHandler(async (req, res) =&gt; {
    console.log(&quot;controller req.user value&quot;);
    console.log(req.user);
    res.json(req.user);
  });
  </code></pre>
  <br>
  But here res.json gives nothing and log give undefined.<br>
  Is it async and await that I am missing?
  How do I solve this?