HTTP reading the _body content


#1

I’m using the HTTP POST request to get a response from the server and I can’t figure out how to get the contents of the _body parameter in my code. Any advice will be highly appreciated.

        this.Provider.Account(value).then((response) => {
            response._body // THIS DOESN'T WORK.....
        });

#2

I use rxjs map method

this.http.post(url,json_to_post)
        .map(response => {
            console.log(response.json()); //this is response._body
        });

#3

I don’t have the .json() menthod. How do I get it to work? Thanks!


#4

response["_body"]

BUT I DON’T KNOW WHY???


#5

maybe because response is a map, not an object!


#6

Since JavaScript has no access control or encapsulation, it has to be done by convention. Leading underscores mean “hands off”. Nobody from outside the object having that property should try to access it.