title: JwtStrategy requires a function to retrieve JWT from requests
body: <p>I got the following error when I tried to extract the JWT token from the authorization header:</p>
  
  <pre><code>TypeError: JwtStrategy requires a function to retrieve jwt from requests (see 
  option jwtFromRequest)
  at new JwtStrategy (C:\MEANauth app\node_modules\passport-jwt\lib\strategy.j
  s:55:15)
  at module.exports (C:\MEANauth app\config\passport.js:10:15)
  at Object.&lt;anonymous&gt; (C:\MEANauth app\app.js:37:29)
  at Module._compile (module.js:643:30)
  at Object.Module._extensions..js (module.js:654:10)
  at Module.load (module.js:556:32)
  at tryModuleLoad (module.js:499:12)
  at Function.Module._load (module.js:491:3)
  at Function.Module.runMain (module.js:684:10)
  at startup (bootstrap_node.js:187:16)
  at bootstrap_node.js:608:3
  </code></pre>
  
  <p>This is the code for passport.js:</p>
  
  <pre><code>const JwtStrategy = require("passport-jwt").Strategy;
  const ExtractJwt = require("passport-jwt").ExtractJwt;
  const User=require("../models/user");
  const config = require("../config/database");
  module.exports = function(passport){
      let opts = {};
      opts.JwtFromRequest = ExtractJwt.fromAuthHeaderWithScheme("jwt");
      opts.secretOrKey = config.secret;
      passport.use(new JwtStrategy(opts,function(jwt_payload,done){//here it points for error
          User.getUserById(jwt_payload._id, function(err,user){
              if(err){
                  return done(err, false);
              }
  
              if(user){
                  return done(null, user);
              }
              else{
                  return done(null, false);
              }
          });
      }));
  }      
  </code></pre>
  
  <p>app.js : this is the main file</p>
  
  <pre><code>const passport =require("passport");
  </code></pre>
  
  <p>here are the passport middleware</p>
  
  <pre><code>//passport middleware
  app.use(passport.initialize());
  app.use(passport.session());
  </code></pre>
  
  <p>//here is the statement it is pointing for error</p>
  
  <pre><code>require('./config/passport')(passport);
  </code></pre>