Skip to content

SyntaxError: Unexpected end of JSON input #19502

@crowmagnumb

Description

@crowmagnumb

I'm submitting a...


[x] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Upgrading to Angular 4.4 suddenly all my API calls that return null give the following ...


SyntaxError: Unexpected end of JSON input SyntaxError: Unexpected end of JSON input at JSON.parse () at XMLHttpRequest.onLoad

... because HttpClient in common/http now interprets null as an empty string which gives the above parse error.

Expected behavior

To return to simply returning a null from calls rather than throwing this parse exception.

Minimal reproduction of the problem with instructions

httpClient.get(url);
httpClient.post(url);

... where the get or post returns a null value with status=200

What is the motivation / use case for changing the behavior?

Supposedly if all my null responses had status 204 (no-content) then it would be handled fine. BUT this turns out to be VERY complicated to achieve. I have been using this API as is for years with no issues. I am in the middle of converting two very large applications that share this same API from AngularJS to Angular. This has been an extremely arduous task claiming me my life for the past month. PLEASE, I beg of you go back to allowing a null response and just treat it as null and NOT as an empty string as all versions of Angular prior to 4.4.4 have done.

I am completely stuck now as I can't go back. We threw ourselves wholly into the Angular Material dependency and now with the latest beta-11 if I drop back to Angular 4.4.3 I get the following in trying to build menus ...


Template parse errors:
There is no directive with "exportAs" set to "mdMenu" 

... I upgraded to 4.4.4 which fixed that issue but now I am having the above so I can't move forward or backwards. HELP!!

Environment


Angular version: 4.4.4


Browser:
- [x] Chrome (desktop) version 60.0.3112.113 (Official Build) (64-bit)
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: v8.2.1  
- Platform:  Mac 

Others:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions