Skip to content

Commit 179fd73

Browse files
authored
Return null value from JSON.Parse
JSON.parse('') will throw a syntax error (in any browser). Fix is to return a null value. I saw this when my server returned HTTP 204 No Content.
1 parent 80b817f commit 179fd73

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/observable/dom/AjaxObservable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ export class AjaxResponse {
396396
case 'json':
397397
if ('response' in xhr) {
398398
//IE does not support json as responseType, parse it internally
399-
this.response = xhr.responseType ? xhr.response : JSON.parse(xhr.response || xhr.responseText || '');
399+
this.response = xhr.responseType ? xhr.response : JSON.parse(xhr.response || xhr.responseText || 'null');
400400
} else {
401401
this.response = JSON.parse(xhr.responseText || '');
402402
}

0 commit comments

Comments
 (0)