Angular 2 http.post()未发送请求 [英] Angular 2 http.post() is not sending the request

查看:86
本文介绍了Angular 2 http.post()未发送请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我发布请求时,Angular 2 http没有发送该请求

When I make a post request the angular 2 http is not sending this request

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

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

the http post is not sent to the server but if I make the request like this

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

这是有意的吗?如果可以,有人可以解释一下我为什么吗?还是一个错误?

Is this intended and if it is can someone explain me why ? Or it is a bug ?

推荐答案

由于Http类的post方法返回一个Observable,因此您需要订阅它才能执行其初始化处理.可观察者是懒惰的.

Since the post method of the Http class returns an observable you need to subscribe it to execute its initialization processing. Observables are lazy.

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

You should have a look at this video for more details:

这篇关于Angular 2 http.post()未发送请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆