我有以下服务,订阅了“ 用户”。
public getEmployees(): Observable<User> {
const url = `${this.baseUrl}/employee`;
return this.http.get<User>(url);
}
我的问题是如何使用用户数据调用getEmployees。我正在尝试使用以下代码,但出现错误?
const _user: User = {
userId: "30294
}
this.userAccountService.getEmployees().subscribe((userprofile: _user) => {
console.log(userprofile.firstName);
});
错误:_user引用值,但在此处使用其类型
将_user
更改为User
。
您正在使用_user
作为userprofile: _user
中的类型