diff options
| author | Misko Hevery | 2010-09-15 18:12:04 +0200 | 
|---|---|---|
| committer | Misko Hevery | 2010-09-16 00:20:35 +0200 | 
| commit | 21e78c443fc5ced77f1ae7e3fc1647f7d9a22115 (patch) | |
| tree | 776143ea43a6ab9a241fe1c9ab1565fbf9d6f9f8 /src/Resource.js | |
| parent | 2acce6a3346129b0b7a0954e9007531ca8f2b4fa (diff) | |
| download | angular.js-21e78c443fc5ced77f1ae7e3fc1647f7d9a22115.tar.bz2 | |
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.
Diffstat (limited to 'src/Resource.js')
| -rw-r--r-- | src/Resource.js | 11 | 
1 files changed, 6 insertions, 5 deletions
| diff --git a/src/Resource.js b/src/Resource.js index 03718b5e..85028dc1 100644 --- a/src/Resource.js +++ b/src/Resource.js @@ -64,7 +64,7 @@ ResourceFactory.prototype = {      foreach(actions, function(action, name){        var isGet = action.method == 'GET'; -      var isPost = action.method == 'POST'; +      var isPostOrPut = action.method == 'POST' || action.method == 'PUT';        Resource[name] = function (a1, a2, a3) {          var params = {};          var data; @@ -81,7 +81,7 @@ ResourceFactory.prototype = {            }          case 1:            if (isFunction(a1)) callback = a1; -          else if (isPost) data = a1; +          else if (isPostOrPut) data = a1;            else params = a1;            break;          case 0: break; @@ -120,7 +120,8 @@ ResourceFactory.prototype = {        if (!isGet) {          Resource.prototype['$' + name] = function(a1, a2){ -          var params = {}; +          var self = this; +          var params = extractParams(self);            var callback = noop;            switch(arguments.length) {            case 2: params = a1; callback = a2; @@ -129,8 +130,8 @@ ResourceFactory.prototype = {            default:              throw "Expected between 1-2 arguments [params, callback], got " + arguments.length + " arguments.";            } -          var self = this; -          Resource[name](params, this, function(response){ +          var data = isPostOrPut ? self : _undefined; +          Resource[name](params, data, function(response){              copy(response, self);              callback(self);            }); | 
