小编典典

Angular 2 http.post() 没有发送请求

all

当我发出 post 请求时,angular 2 http 未发送此请求

this.http.post(this.adminUsersControllerRoute, JSON.stringify(user), this.getRequestOptions())

http post 不会发送到服务器,但如果我发出这样的请求

this.http.post(this.adminUsersControllerRoute, JSON.stringify(user), this.getRequestOptions()).subscribe(r=>{});

这是有意的吗?如果有人可以解释我为什么?或者它是一个错误?


阅读 59

收藏
2022-08-29

共1个答案

小编典典

由于该类的post方法Http返回一个可观察对象,因此您需要订阅它以执行其初始化处理。Observables 是惰性的。

您应该观看此视频以了解更多详细信息:

2022-08-29