title: How can i assign an object as a property of another object in nodejs
body: <p>I am trying to assign an object 'user' as a property of another object 'req.user' like this (req.user = user) in a custom authentication function 'auth' so i can easily use it in a route '/users/me' to send a specific user profile.Here are my codes snippet.I will be so gratefull if i can get a valid help from any one here as soon as possible. </p>
  
  <p>CODE 1 - The Authentication code</p>
  
  <pre><code>`const auth = async(req,res,next)=&gt;{
      try{
          const token = req.header('Authorization').replace('Bearer ','')
          const decoded = jwt.verify(token,'Mysignupstring')
          const user = User.findOne({_id:decoded._id,'tokens.token':token})
          if(!user){
              throw new Error
          }
          req.user = user // Where am having issues 
  
          next()
      }
      catch(e){
          res.status(401).send('Pls Authenticate')
      }
  }`
  </code></pre>
  
  <p>CODE 2 - Is the route code </p>
  
  <pre><code>   router.get('/users/me',auth,async(req,res)=&gt;{
       res.send(req.user)
  
  
    })
  </code></pre>
  
  <p>CODE 3 - Is the Error code</p>
  
  <pre><code>(node:6464) UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON
      at JSON.stringify (&lt;anonymous&gt;)
  </code></pre>
  
  <p>I will be glad to have your help shortly.</p>