aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAnthony Lieuallen2011-03-22 13:51:48 -0400
committerIgor Minar2011-03-29 00:25:22 -0700
commit94514a91f8e352e97c5eb44cdace29643e57f9d6 (patch)
tree4e78d1258b2adbddc5ee9e43d1a39ea63d35fdf3 /src
parent4da65d0e8c6a3bfbe5b2c4ad5708a39e750f739a (diff)
downloadangular.js-94514a91f8e352e97c5eb44cdace29643e57f9d6.tar.bz2
Don't mutate resource if server responded with no body
If the server provides response with no body to a resource request, resource should not mutate the resource model in the callback.
Diffstat (limited to 'src')
-rw-r--r--src/Resource.js16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/Resource.js b/src/Resource.js
index b686d930..ade110db 100644
--- a/src/Resource.js
+++ b/src/Resource.js
@@ -97,13 +97,15 @@ ResourceFactory.prototype = {
data,
function(status, response, clear) {
if (status == 200) {
- if (action.isArray) {
- value.length = 0;
- forEach(response, function(item){
- value.push(new Resource(item));
- });
- } else {
- copy(response, value);
+ if (response) {
+ if (action.isArray) {
+ value.length = 0;
+ forEach(response, function(item){
+ value.push(new Resource(item));
+ });
+ } else {
+ copy(response, value);
+ }
}
(callback||noop)(value);
} else {