Skip to content

Commit c7d944f

Browse files
authored
fix: add head, 204 parser handling
This behavior improves jquery compatibility. See https://github.com/jquery/jquery/blob/df6858df2ed3fc5c424591a5e09b900eb4ce0417/src/ajax.js#L762-L780
1 parent 13e2138 commit c7d944f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

backbone.fetch.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
};
3030

3131
var getData = function(response, dataType) {
32+
if (response.status === 204) return null;
3233
return dataType === 'json' ? response.json() : response.text();
3334
};
3435

@@ -49,7 +50,9 @@
4950

5051
return fetch(options.url, options)
5152
.then(function(response) {
52-
var promise = getData(response, options.dataType);
53+
var promise = options.type === 'HEAD'
54+
? null
55+
: getData(response, options.dataType);
5356

5457
if (response.ok) return promise;
5558

0 commit comments

Comments
 (0)