Api call with header id token

i want to access remote api call with id token , how can i do??any sugesstion,thanks…

Check angular interceptor. This will help you.
ionic interceptor

1 Like

let headers = new Headers();
headers.append(‘token-name’, ‘value’);
console.log(“suc2”);
let body = {

             };
                 this.http.post('https://xxxx.in/p/api/diagnostics/getQueueStatus', JSON.stringify(body),{headers:headers})

.map(res => res.json())
.subscribe(data =>{
console.log(data);

          });

Yes this will also work , but if you need to add this token header with all the service call you need to repeat this code. You can use the intercptor method for adding the token header with each api call automatically.

1 Like