Ionic 3 pass jwt_token in header to laravel app

i'm trying to send a get to url passing a jwt token, so far i've got this: The server is build on laravel, and works perfectly with postman passing token on header, but not ataching like the code below

import { Http } from '@angular/http';
import { Storage } from '@ionic/storage';
import { HTTP } from '@ionic-native/http';
import { HttpClient } from '@angular/common/http';

constructor(
    public http: HttpClient,
    public httpnative: Http,
    private storage: Storage
  )



PostToApi(endpoint:any, body:any, headers:any){
  return this.http.post(this.apiurl+endpoint, body, headers);
}
PostData(){
this.storage.get('jwt_token').then(token=>{
 let body = new FormData();
 body.append('data_nasc', '07-04-1991');

 let headers = new Headers();
 headers.append('Content-Type', 'application/x-www-form-urlencoded');
 headers.append('Accept', 'application/json');
 headers.append('Authorization', 'Bearer ' + token);

 this.webservices.PostToApi('/cliente/perfil',body,headers).subscribe(
  data => {
    let dados:any;
    dados = data;
    let retorno: any;
    retorno = JSON.parse(dados._body);
    console.log(JSON.stringify(retorno));
  },
  error => {
    console.log(error._body);
  },
  () => {
  }
);
});
}

WHen i send this data i've got an token_not_provided error on console.log error._body

PS. im willing to pay for a solution to this

angularlaraveltypescriptionic3jwt

Answers

comments powered by Disqus