Authentication using passport jwt from angular app I am setting my request header in angular 4 as I am using passport jwt in server side but i am getting unauthorized error
`let strategy = new JwtStrategy(jwtOpts, (jwt_payload, cb)=>{
let stmt = "select * from user where id = ?";
let id = jwt_payload.id;
connection.query(stmt, id, (error, result) => {
if(error){
throw error;
}
if(result){
var userinfo = {
email: result[0].email,
id: result[0].id
}
cb(null, userinfo);
}
else{
cb(null, false);
}
})
})`
//this is my route
`app.use('/tournament',passport.authenticate('jwt', {session: false}), tour_route);`
//This is my angular call
createTournament(name: string){
this.token = 'JWT ' + this.authService.getToken();
const body = {
name
}
this.http.post('http://localhost:8000/tournament',
{
headers: new HttpHeaders().set('Authorization', this.token)
})
.subscribe(
response => {}
);
}
But i am getting an unauthorised access even if i am sending the right token