ionic3 - 离子服务错误:“响应”类型上不存在属性“用户”
问题描述
我找不到合适的解决方案,我有代码
登录.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)
});
});
}
身份验证服务.ts
public login(credentials) {
return this.http.post(this.apiUrl + '/appLogin', JSON.stringify(credentials))
.map((response: Response) => response);
}
我在ionic serve上遇到了这个错误。为什么会这样?。
解决方案
我通过给定的代码解决了我的问题
身份验证服务.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 提供参考
推荐阅读
- xamarin.forms - Xamarin.Form CollectionView 正在随机检查 RadioButtons
- cypress - 验证请求的次数
- python-3.x - Aiogram Webhook Bot + Ngrok 问题
- android - 在使用 android videoview 时捕获所有可能的异常
- javascript - Javascript嵌套异步调用执行顺序
- javascript - 我无法从状态渲染和对象,ReactJS 与功能组件
- php - 如何从 SQL 中显示标题和 URL
- php - 如何在一张表中存储不同的报告(MySQL + PHP)
- python - 如何摆脱python中的一个空白?
- javascript - 创建 HTML 元素时如何选择未使用的变量名?