离子服务错误:属性 'user' 在类型 'Response' 上不存在
Error on ionic serve : Property 'user' does not exist on type 'Response'
我找不到合适的解决方案,我有代码
login.ts
login() {
if(!this.login_form.valid)
return;
this.AuthService.login(this.login_form.value).subscribe((result) => {
if((result.status).toString() == "Success" && result.user){
localStorage.setItem('userData', JSON.stringify(result.user));
this.nav.setRoot(HomePage);
}
}, (err) => {
console.log(err)
});
});
}
AuthService.ts
public login(credentials) {
return this.http.post(this.apiUrl + '/appLogin', JSON.stringify(credentials))
.map((response: Response) => response);
}
我在 ionic serve 上收到此错误。为什么会这样?
这是我的错误
我通过给定的代码解决了我的问题
AuthService.ts
export interface User {
status: string;
user: {};
}
public login(credentials) {
return this.http.post(this.apiUrl + '/appLogin', JSON.stringify(credentials))
.map((response: User) => response);
}
感谢@phonolog 提供参考
我找不到合适的解决方案,我有代码
login.ts
login() {
if(!this.login_form.valid)
return;
this.AuthService.login(this.login_form.value).subscribe((result) => {
if((result.status).toString() == "Success" && result.user){
localStorage.setItem('userData', JSON.stringify(result.user));
this.nav.setRoot(HomePage);
}
}, (err) => {
console.log(err)
});
});
}
AuthService.ts
public login(credentials) {
return this.http.post(this.apiUrl + '/appLogin', JSON.stringify(credentials))
.map((response: Response) => response);
}
我在 ionic serve 上收到此错误。为什么会这样?
这是我的错误
我通过给定的代码解决了我的问题
AuthService.ts
export interface User {
status: string;
user: {};
}
public login(credentials) {
return this.http.post(this.apiUrl + '/appLogin', JSON.stringify(credentials))
.map((response: User) => response);
}
感谢@phonolog 提供参考