订户返回订户不是信息
Subscriber returning subscriber not info
我正在尝试访问我的服务中的 HTTP 请求的结果:
getFriendsProfile(email) {
return this.http.get(environment.apiBaseUrl + '/profile/' + email);
}
但是,console.logging 用户个人资料 returns 是订阅者,但不是我要查找的信息。我如何获取信息?
ngOnInit() {
this.userProfile = this.userService.getUserProfile().subscribe((res) => {
this.userProfile = res;
});
console.log(this.userProfile);
}
不要将 userProfile 设置为订阅,而是仅在订阅回调中设置它。
ngOnInit() {
this.userService.getUserProfile().subscribe((res) => {
this.userProfile = res;
console.log(this.userProfile);
});
}
我正在尝试访问我的服务中的 HTTP 请求的结果:
getFriendsProfile(email) {
return this.http.get(environment.apiBaseUrl + '/profile/' + email);
}
但是,console.logging 用户个人资料 returns 是订阅者,但不是我要查找的信息。我如何获取信息?
ngOnInit() {
this.userProfile = this.userService.getUserProfile().subscribe((res) => {
this.userProfile = res;
});
console.log(this.userProfile);
}
不要将 userProfile 设置为订阅,而是仅在订阅回调中设置它。
ngOnInit() {
this.userService.getUserProfile().subscribe((res) => {
this.userProfile = res;
console.log(this.userProfile);
});
}