我在JWT上使用的是以下内容:
let jwtoptions = {};
jwtoptions.jwtFromRequest = ExtractJWT.fromAuthHeaderAsBearerToken();
jwtoptions.secretOrKey = DB.secret;
let Strategy = new JWTStrategy(jwtoptions,(jwt_payload,done)=>{
User.findById(jwt_payload.id)
.then(User =>{
return done(null, User);
})
.catch(err =>{
return done(err,false);
})
})
passport.use(Strategy);
但它向我展示了下面的错误:
(node:14224) UnhandledPromiseRejectionWarning: TypeError: done is not a function
(node:13568) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().