this.http.post(...)。map不是函数

时间:2016-08-18 22:42:18

标签: 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语法中缺少什么?

1 个答案:

答案 0 :(得分:4)

您需要导入像

这样的rxjs
import 'rxjs/Rx';