-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Response interceptor on resource does not allow me to change data #4407
Comments
I guess, transformResponse should be used for modifying data - but this is not documented. |
angular1.2rc2 |
Correct way to modify response is obviously:
|
It is documented here: http://docs.angularjs.org/api/ng.$http under the section entitled "Transforming Requests and Responses" |
The documentation link points to $http service, while this is using $resource. |
@honzajde I knot this post is really old, but I was also looking for a solution and didn't found one on the internet. In the function you provided, you should be modifying |
@piteer1 I have the same problem with interceptor. Your solution works but response.resource cannot be replaced. We have to modified the values inside the reference … less handy than transformResponse but with transformResponse i cannot get the status code … |
I think it's weird that passing an interceptor into an action on a $resource doesn't let the interceptor intercept requests, only responses. For example: var Thing = $resource('/thing/:id',
{thingId:'@id'},
{
foo: {method:'POST', interceptor: myInterceptor}
}
); myInterceptor will only intercept the response of Thing.foo(), NOT the request... |
I know this issue is closed, but for anyone who search : To modify the data in a resource interceptor, you need to modify response.data and response.resource. Example of the weird behaviour : live example with AngularJS 1.2.27 : http://jsfiddle.net/605twneu/2/ Should I open an issue ? What do you think ? |
If anyone still search for answer look at this issue #11409, there is detailed discussion about interceptors and why $resource interceptors different from $http. |
After resource is resolved it should be tags but its data.
The text was updated successfully, but these errors were encountered: