I can not send the correct headings in angular 7! I use passport on my backend:
"app.get('/api/users', passport.authenticate('jwt', {session: false}), (req, res, next) => {... bla bla bla...}."
When I try send a valid token from postman to my path / api / users everything works correctly, but when i do it from angular not. (*Angular dont show error!) Suppose 'Bearer validToken' is a valid token In this way i send the headers:
getAll() {
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': 'Bearer validToke.'
});
};
return this.http.get<user[]>(`http://localhost:3000/api/users`, httpOptions);
}
I can authenticate from angular and get the Bearer token, everything works correctly, I can get the list of users if I remove passport.authenticate ('jwt', {session: false})
Thank you for reading!