0

I am trying to fetch access-token and uid from response headers of a post request, which looks like this enter image description here

this is how i am trying to achieve it from service side

signup(postObj: any){
let url = environment.apiBaseUrl + "/v1/leads";
return this.http.post(url, postObj,{observe: 'response'});
}

Component side code

this.apartmentService.signup(obj).subscribe(data => {
console.log(data);
this.toastr.success('Registered successfully');
console.log(this.citydata,'this.citydata');

}

enter image description here The method is not giving any response headers. Itried many solutions on internet but nothing works for me.

Any lead would be very helpful

manish joshi
  • 55
  • 2
  • 8

1 Answers1

0

Please try once with the below component side code and check whether required response headers are getting fetched or not -

this.apartmentService.signup(obj).subscribe((data: any) => {
console.log('access token: ', data.headers.get('access-token'));
console.log('uid: ', data.headers.get('uid'));
});

OR

this.apartmentService.signup(obj).subscribe((data: any) => {
console.log('access token: ', JSON.parse(data.headers.get('access-token')));
console.log('uid: ', JSON.parse(data.headers.get('uid')));
});