Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 21e78c4

Browse files
committed
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.
1 parent 2acce6a commit 21e78c4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Resource.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ ResourceFactory.prototype = {
6464

6565
foreach(actions, function(action, name){
6666
var isGet = action.method == 'GET';
67-
var isPost = action.method == 'POST';
67+
var isPostOrPut = action.method == 'POST' || action.method == 'PUT';
6868
Resource[name] = function (a1, a2, a3) {
6969
var params = {};
7070
var data;
@@ -81,7 +81,7 @@ ResourceFactory.prototype = {
8181
}
8282
case 1:
8383
if (isFunction(a1)) callback = a1;
84-
else if (isPost) data = a1;
84+
else if (isPostOrPut) data = a1;
8585
else params = a1;
8686
break;
8787
case 0: break;
@@ -120,7 +120,8 @@ ResourceFactory.prototype = {
120120

121121
if (!isGet) {
122122
Resource.prototype['$' + name] = function(a1, a2){
123-
var params = {};
123+
var self = this;
124+
var params = extractParams(self);
124125
var callback = noop;
125126
switch(arguments.length) {
126127
case 2: params = a1; callback = a2;
@@ -129,8 +130,8 @@ ResourceFactory.prototype = {
129130
default:
130131
throw "Expected between 1-2 arguments [params, callback], got " + arguments.length + " arguments.";
131132
}
132-
var self = this;
133-
Resource[name](params, this, function(response){
133+
var data = isPostOrPut ? self : _undefined;
134+
Resource[name](params, data, function(response){
134135
copy(response, self);
135136
callback(self);
136137
});

0 commit comments

Comments
 (0)