Skip to content

Commit 13e2138

Browse files
committed
Merge pull request #8 from SpaceK33z/fix-undefined-argument
Fix undefined argument in `then` when using options.success
2 parents b0c74af + 79252b9 commit 13e2138

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

backbone.fetch.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@
6161
throw error;
6262
});
6363
})
64-
.then(options.success);
64+
.then(function(responseData) {
65+
if (options.success) options.success(responseData);
66+
return responseData;
67+
});
6568
};
6669

6770
if (typeof exports === 'object') {

test/fetch.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ describe('backbone.fetch', function() {
124124
success: function(response) {
125125
expect(response).to.deep.equal({status: 'ok'});
126126
}
127+
}).then(function(response) {
128+
expect(response).to.deep.equal({status: 'ok'});
127129
});
128130
server.respond('{"status": "ok"}');
129131
return promise;

0 commit comments

Comments
 (0)