title: Express JS : always get message : TypeError: Assignment to constant variable
body: <p>I am  trying to create API with Express JS ,the API worked fine ,I made authorization for some routes with JsonWebToken package ,it is create token fine ,but when I used it I gave this error: <strong>TypeError: Assignment to constant variable.</strong>
  the user controller sign in :</p>
  <pre><code>    login:(req,res)=&gt;{
          const body=req.body;
  
          checkUserByEmail(body.email,(err,results)=&gt;{
              if(err){
                  return err;
              }
              else if(!results){
                  return res.json({
                      success:0,
                      message : 'email not registered!'
                  });
              }
              else{
                  const result = bcrypt.compareSync(body.password,results.password);
                  if(result){
  
                      const jsonToken = sign({
                          email:body.email,
                          name:results.name
                      },process.env.TOKEN_KEY,
                          {expiresIn : 60*60*24*30*12});
                      return res.json({
                          success:1,
                          message:'loggin successfully',
                          token :jsonToken
                      })  
                  }
                  else{
                      res.json({
                          success:0,
                          message:'password is wrong'
                      })
                  }
              }
          })
      },
  </code></pre>
  <p>My auth method :</p>
  <pre><code>module.exports = {
      checkToken :(req,res,next)=&gt;{
          const token = req.get('authorization');
          if(token){
              console.log(token);
              
              token=token.slice(7);
              verify(token,process.env.TOKEN_KEY,(err,decoded)=&gt;{
                  if(err){
                      return res.json({
                          success:0,
                          messgae:'invalid token'
                      });
                  }else{
                      next();
                  }
              })
          }
          else {
              return res.json({
                  success:0,
                  messgae:'access not allowed'
              });
          }
      }
  }
  </code></pre>
  <h2>Can any one help?</h2>