正在调用其他API,而不是等待注销api响应。
当我单击注销时(会调用api),但仪表板api也会在重定向到注销页面之前立即被调用。
Component.ts
this.loginService.logoutApi().subscribe((data) =>{
this.storage.set(STORAGE_LOGIN_RES,'');
this.router.navigate(['/login'])
console.log(this.storage.get(STORAGE_LOGIN_RES));
},
(error: any) => {
this.isError = "Contact your administrator.";
}
);
Service.ts
try {
let url = WebUrls.logoutApi;
let user_details = this.getSession();
let headers = new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': user_details
});
let options = { headers: headers,observe: 'response' };
return this.http.get(url,{
headers: headers,
observe: 'response'
})
} catch (e) { console.log(e) }