Reputation: 123
I have an Angular 4 application which calls an API with NTLM Authentication. It returns 2 401's then the 200 response, however, the subscribed response in Angular returns undefined for the response, as it appears to get the first 401. In Fiddler I can see everything I need in the 200 response, but it is preceded by the two 401's. How do I get the 200 response data?
Service.ts
getCurrentUser(): Observable<any> {
let options = new RequestOptions({ withCredentials: true });
return this.http.get(urlBase, options)
.map((response: any) => { return response.json() });
}
Component.ts
getUser() {
let result: any;
this._userService.getCurrentUser()
.subscribe(
data => result = data
);
console.log(result);
}
Upvotes: 2
Views: 2693
Reputation: 123
Turns out I was missing brackets around the this.result = data; It works now.
getUser() {
this._userService.getCurrentUser()
.subscribe(
data => {
this.result = data;
console.log(this.result);
});
};
Upvotes: 1