【发布时间】:2018-08-23 14:39:21
【问题描述】:
我正在发出一个 HttpClient 获取请求,并将响应返回给我的组件。我似乎无法对响应做任何事情。
这是我调用服务的组件方法:
onSubmit() {
this.userService.updateProfile(this.userForm.value)
.subscribe(response => {
console.log(response); //This does not log to the console
});
}
这是我的服务:
updateProfile(user: User) {
return this.httpClient.put<User>('/updateUser', user)
.map(response => {
console.log(response); //This does not log to the console
return response;
});
}
我无法在我的服务或组件中将响应记录到控制台。我没有任何编译错误或任何表明存在问题的东西。
【问题讨论】:
-
欢迎堆栈溢出!有没有可能在看跌期权时你没有得到任何东西来记录?许多
put操作不会像get和post那样返回数据。 -
感谢您的帮助。我刚刚测试了发布请求,没有运气。我无法执行获取请求,因为我在正文中传递了一个对象。
-
您使用的是来自
@angular/common/http的HttpClientModule吗?
标签: angular rxjs httpclient subscription