I need to send my jwt Token with the headers and it works fine in Postman but when i try it in Ionic with that Code.
ync setAnzahlTische() {
var headers = new Headers();
headers.append('Accept', 'application/json');
headers.append('Content-Type', 'application/json' );
this.storage.get('token').then((val) => {
headers.set('Authorization', val);
});
headers.append('Access-Control-Allow-Origin', '*');
headers.append('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
headers.append('x-Trigger', 'CORS');
let tos = JSON.stringify(postData);
this.http.post('http://127.0.0.1:8000/updatedata', tos, {responseType: 'text'})
.subscribe(data => {
this.router.navigate(['/home']);
}, error => {
console.log(error.message);
});
}
I have shortened the Code a little bit but the important things are still there. I get Access denied when i try to do the http.post but the JWT token is valid. I think the headers are undefined but im not sure.