Closed edusfc15 closed 6 years ago
Hello and thank you for purchasing the book.
Your findings are correct, the earlier versions of the Angular 5 HttpClient expect a Json result by default - unless you specifically tell Angular not to expect JSON - and will throw a SyntaxError (actually a Json parse error) if the response they receive comes with a HTTP-200 with an empty body.
Notice that such behaviour has been fixed on December 2017, so that the XhrBackend
will attempt the JSON parse only if the response body is non-empty (otherwise, the body is left as null):
https://github.com/angular/angular/issues/19502
Most recent versions of Angular (>= 2018) should be able to properly support the OkResult()
: if you're using earlier builds, NoContentResult()
is the way to go.
That said, since the book recommends to use Angular 5.0.2 which is older than the above mentioned patch, I'll flag this as a BOOK ERRATA (although it's more an Angular bug) and push your solution as a viable fix.
Thanks a lot for your findings!
Hello,
there is a problem when deleting a quiz:
The quiz is deleted, but remains in the same route.
seems that the problem is in the return of the quizcontroller delete action:
return new OkResult();
if we change to :
return new NoContentResult()
it fix the problem.