mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-14 09:43:12 +00:00
Delete requests on resources pass this as data. Delete requests should not be passing data in the body of the response. The bug is here:
http://github.com/angular/angular.js/blob/master/src/Resource.js#L119 Instead of checking for !isGet you should be checking for !isPost. Also isPost should be isPostOrPut since only on those two methods should be sending a payload if I am not mistaken.
This commit is contained in:
parent
2acce6a334
commit
21e78c443f
1 changed files with 6 additions and 5 deletions
|
|
@ -64,7 +64,7 @@ ResourceFactory.prototype = {
|
||||||
|
|
||||||
foreach(actions, function(action, name){
|
foreach(actions, function(action, name){
|
||||||
var isGet = action.method == 'GET';
|
var isGet = action.method == 'GET';
|
||||||
var isPost = action.method == 'POST';
|
var isPostOrPut = action.method == 'POST' || action.method == 'PUT';
|
||||||
Resource[name] = function (a1, a2, a3) {
|
Resource[name] = function (a1, a2, a3) {
|
||||||
var params = {};
|
var params = {};
|
||||||
var data;
|
var data;
|
||||||
|
|
@ -81,7 +81,7 @@ ResourceFactory.prototype = {
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
if (isFunction(a1)) callback = a1;
|
if (isFunction(a1)) callback = a1;
|
||||||
else if (isPost) data = a1;
|
else if (isPostOrPut) data = a1;
|
||||||
else params = a1;
|
else params = a1;
|
||||||
break;
|
break;
|
||||||
case 0: break;
|
case 0: break;
|
||||||
|
|
@ -120,7 +120,8 @@ ResourceFactory.prototype = {
|
||||||
|
|
||||||
if (!isGet) {
|
if (!isGet) {
|
||||||
Resource.prototype['$' + name] = function(a1, a2){
|
Resource.prototype['$' + name] = function(a1, a2){
|
||||||
var params = {};
|
var self = this;
|
||||||
|
var params = extractParams(self);
|
||||||
var callback = noop;
|
var callback = noop;
|
||||||
switch(arguments.length) {
|
switch(arguments.length) {
|
||||||
case 2: params = a1; callback = a2;
|
case 2: params = a1; callback = a2;
|
||||||
|
|
@ -129,8 +130,8 @@ ResourceFactory.prototype = {
|
||||||
default:
|
default:
|
||||||
throw "Expected between 1-2 arguments [params, callback], got " + arguments.length + " arguments.";
|
throw "Expected between 1-2 arguments [params, callback], got " + arguments.length + " arguments.";
|
||||||
}
|
}
|
||||||
var self = this;
|
var data = isPostOrPut ? self : _undefined;
|
||||||
Resource[name](params, this, function(response){
|
Resource[name](params, data, function(response){
|
||||||
copy(response, self);
|
copy(response, self);
|
||||||
callback(self);
|
callback(self);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue