Http request not working - _this.http.post(...).map is not a function


#1

I have the following code:

var headers = new Headers();
headers.append(‘Content-Type’, ‘application/json’);

    this.http.post(
        'http://www.syntaxsuccess.com/poc-post/', 
        JSON.stringify({firstName:'Joe',lastName:'Smith'}),
        {headers:headers}
    ).map(
        (res: Response) => res.json()
    ).subscribe(
        (res:Person) => {
            this.postResponse = res;
            console.log("VALUE RECEIVED: ",res);
        },
        (x) => {
            /* this function is executed when there's an ERROR */
            console.log("ERROR: "+x);
        },
        () => {
            /* this function is executed when the observable ends (completes) its stream */
            console.log("Completed");
        }
    );

but I keep getting the error:

_this.http.post(…).map is not a function

. How can I fix this?

Cheers


#2

Can you post the code from your constructor?

It appears as though you never define the http property of this class.