title: How to get user.id from jwt token in Node.js?
body: <p>In my User controller, I create a token in which I save this user's id when he login to my application.</p>
  
  <pre><code>exports.findOne = (req, res) =&gt; {
    User.findOne({
      where: {
        login: req.body.login,
      },
    })
      .then(user =&gt; {
        if (user) {
          if (bcrypt.compareSync(req.body.password, user.password)) {
            const token = jwt.sign(
              {
                id: user.id, // this is the id I need.
              },
              env.SECRET_KEY,
              {
                expiresIn: 129600,
              },
            );
            return res.status(200).json({
              message: 'Auth successful',
              token,
            });
          }
         ...
        }
      })
      .catch(err =&gt; {
        res.status(400).json({ error: err });
      });
  };
  </code></pre>
  
  <p>Now in another controller I would like to read this id and use it for my purpose. How can I get to it?</p>
  
  <pre><code>       const loginId = '?'; // here I want to give it to id
              Bill.update(
                {
                  available_funds: available_funds - amountMoney,
                },
                { where: { id_owner: loginId } },
              ).then(() =&gt; {
                res.status(200).send(`ok`);
              });
  </code></pre>