How can I get access to the Angular 2 http response body without converting it to string or json? How can I get access to the Angular 2 http response body without converting it to string or json? angular angular

How can I get access to the Angular 2 http response body without converting it to string or json?


There's a much simpler solution to accessing the body as a string which I haven't seen documented anywhere:

let body = res.text()


Addon to @StudioLE. You may use json() method to return data as json.

let body = res.json()


Since I found this question while running into the same problem (and Angular's documentation is not updated as of today) you can now use:

let blob = new Blob([response.arrayBuffer()], { type: contentType });

Another workaround if you for some reason are on an old version of Angular 2 is:

let blob = new Blob([(<any> response)._body], { type: contentType });