Api call with header id token


#1

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


#2

Check angular interceptor. This will help you.
ionic interceptor


#3

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);

          });

#4

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.