不带.subscribe回调的有角http.post [英] Angular http.post without .subscribe callback

查看:123
本文介绍了不带.subscribe回调的有角http.post的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我是否可以仅发出http 发布请求而无需订阅回调

I'm wondering if I can make just a http post request without subscribing on callbacks, something like this

 this._http.post('/list/items/update?itemId=' + itemId + "&done=" + done, null);

代替此

 this._http.post('/list/items/update?itemId=' + itemId + "&done=" + done, null)
        .subscribe();

推荐答案

我认为你不能.

http.post(以及获取,放置,删除等)返回一个冷的Observable,即:

http.post (and get, put, delete, etc) returns a cold Observable, i.e. an Observable for which:

其基本生产者是在订阅期间创建和激活的

its underlying producer is created and activated during subscription

来源.

这意味着Observable表示的功能只能通过subscribe()方法激活.

This means the function represented by the Observable is activated only with the subscribe() method.

这篇关于不带.subscribe回调的有角http.post的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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