mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
feat($http): make the transform defaults to an array
$httpProvider.defaults.transformRequest and $httpProvider.defaults.transformResponse are now arrays containing single function. This makes it easy to add an extra transform fn. adding an extra fn before had to be done in this cluncky way: $httpProvider.defaults.transformResponse = [$httpProvider.defaults.transformResponse, myTransformFn]; after this change, it's simply: $httpProvider.defaults.transformResponse.push(myTransformFn);
This commit is contained in:
parent
13a95ae499
commit
a8a750ab05
1 changed files with 4 additions and 4 deletions
|
|
@ -90,7 +90,7 @@ function $HttpProvider() {
|
|||
|
||||
var $config = this.defaults = {
|
||||
// transform incoming response data
|
||||
transformResponse: function(data) {
|
||||
transformResponse: [function(data) {
|
||||
if (isString(data)) {
|
||||
// strip json vulnerability protection prefix
|
||||
data = data.replace(PROTECTION_PREFIX, '');
|
||||
|
|
@ -98,12 +98,12 @@ function $HttpProvider() {
|
|||
data = fromJson(data, true);
|
||||
}
|
||||
return data;
|
||||
},
|
||||
}],
|
||||
|
||||
// transform outgoing request data
|
||||
transformRequest: function(d) {
|
||||
transformRequest: [function(d) {
|
||||
return isObject(d) && !isFile(d) ? toJson(d) : d;
|
||||
},
|
||||
}],
|
||||
|
||||
// default headers
|
||||
headers: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue