-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Resource response transformation executed before HTTP interceptor #7594
Comments
I ran into this today. When specifying an interceptor for a $resource action, the response interceptor runs after the response.resource object has been populated. I need to transform the data before the resources are constructed. |
If I understand your use-case correctly, if you want to modify the data before they are turned into the |
I also ran into this today, running angular & angular-resource 1.3.3. Added a method to $http.defaults.transformResponses chain that catches /Unauthorized/.test(arguments[0]) Any progress / updates? |
A fix landed in master (1b74097) that makes it possible to inspect response status code in the response data transformer function and take an appropriate action based on this status. Hopefully this is enough to address this issue as now people can avoid response data transformation for failed requests. Closing this for now, please open a separate issue if anything is missing after this change. |
To anyone coming here from Google like I did: I also found it to be confusing that response interceptors run after the So, if you need to basically have a response interceptor that runs before the 'use strict';
angular.module('app')
.run(function ($http) {
$http.defaults.transformResponse.push(function (data, headers) {
// do stuff here before the response transformation
// Be sure to return `data` so that the next function in the queue can use it.
// Your services won't load otherwise!
return data;
});
}); If your services or http calls don't have their own response transformer, you're good now. If your services do have their own To circumvent this, you can follow this example in the docs. |
Shouldn't it be the other way around? I would not want to transform a 401-response.
The text was updated successfully, but these errors were encountered: