Can I return raw json response in angular2
Yes off course you can !!
Actually angualar2 returns Response in the form of Observable
instead of promise Like in angular1.x , so in order to convert that observable into raw Json format we have to use the default method of angular2 i.e
res.json()
There are no of method apart from .json()
provided by angular which can be described here for more info.
methods include
- res.text()
- res.status
- res.statusTextetc
https://angular.io/docs/ts/latest/api/http/index/Response-class.html
update
use your code like this
return this.http.post(URL, body, options) .map(res => {return res.json()}) .catch(this.handleError); }