http - this.http.post(...).map 不是一个函数

标签 http angular

doSelectMessagesAttributesUrl1(pushRequest : PushRequest) {
    console.info("sending post request");

    let headers = new Headers({
        'Content-Type': 'application/x-www-form-urlencoded'});

    return this.http
        .post(this.selectMessagesAttributesUrl, {headers: headers})
        .map(res => res.json().data)
        .subscribe(
            data => { },
            err => { console.error('An error occurred', err) }
        );
}

我收到此错误:

EXCEPTION: TypeError: this.http.post(...).map is not a functionBrowserDomAdapter.logError @ platform-browser.umd.js:937
zone.js:461 

Unhandled Promise rejection: this.http.post(...).map is not a function ; Zone: <root> ; Task: Promise.then ; Value: TypeError: this.http.post(...).map is not a function(…)

我的 http 语法缺少什么?

最佳答案

你需要像这样导入rxjs

import 'rxjs/Rx';

关于http - this.http.post(...).map 不是一个函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39028585/

相关文章:

apache - HTTP KeepAlive 连接被服务器关闭但客户端同时发送了一个请求

Java JSch SSH 隧道发送 HTTP 或 HTTPs 请求到远程服务器

angular - Angular 5 中的动态组件和事件发射器

typescript - 如何从内部具有 Observable 订阅的函数返回值?

angular - 在 Angular 中操作/引用 DOM 元素的正确方法

ios - 如何从ios中的非ui线程发送http请求

http - 为什么 google.com 不在 HSTS 响应 header 上设置 includeSubDomains 指令?

javascript - 服务器响应 500 错误时触发 XMLHttp Request .upload.onprogress

angular - 使用 Font Awesome Icons 模块测试组件

node.js - 如何将 Angular 应用程序部署到生产环境