I am new to Angular/RxJS etc. I want to make two HTTP requests sequentially. I assumed if I call the next method in the complete function of first observable it should run sequentially, but that is not the case.
login(): boolean {
let windowsAuthToken: string;
var result = this.http.get(this.authUrl).subscribe(
(response: any) => {
windowsAuthToken = response.token;
},
err => {},
() => {
return this.performWindowsAuthentication(windowsAuthToken);
}
);
return false;
}
performWindowsAuthentication(windowsAuthToken: string): boolean {
if (!!windowsAuthToken) {
const loginRequest = new WindowsLoginRequest(windowsAuthToken);
this.http
.post<WindowsLoginRequest>(this.winLoginUrl, loginRequest)
.subscribe(
(response: any) => {
if (response) {
localStorage.setItem(Constants.jwtToken, response.jwt);
}
},
err => this.logger.logError("Failed to get JWT token", err),
() => {
return true;
}
);
} else {
return false;
}
}