Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70612

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

$
0
0

@polska03 wrote:

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

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70612

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>