title: How to set authorization header in node js?
body: <p>Hello I am working on node application in which I am working on jsonwebtokens,passport-jwt.I created application backend side and working fine on postman but I stuck on front end side. when i send token in headers in postman then token based page open on postman fine but on front side display unauthorized.How can i send token in header so that this page also open on front end side.
  My code:</p>
  
  <pre><code>app.post("/login", function(req, res) {
    if(req.body.name &amp;&amp; req.body.password){
      var name = req.body.name;
      var password = req.body.password;
    }
  
    var user = users[_.findIndex(users, {name: name})];
    if( ! user ){
      res.status(401).json({message:"no such user found"});
    }
  
    if(user.password === req.body.password) {
      // from now on we'll identify the user by the id and the id is the only personalized value that goes into our token
      var payload = {id: user.id};
      var token = jwt.sign(payload, jwtOptions.secretOrKey);
      //res.json({message: "ok", token: token});
     res.redirect('/secret')
    } else {
      res.status(401).json({message:"passwords did not match"});
    }
  });
  
  app.get("/secret", passport.authenticate('jwt', { session: false }), function(req, res){
      res.json("Success! You can not see this without a token");
  
    });
  </code></pre>
  
  <p>Where am i doing wrong??</p>