I have an angular project and I have the following error:
ERROR SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at Response.Body.json (http.js:1091)
at SafeSubscriber.eval [as _next] (home.component.ts:57)
at SafeSubscriber.__tryOrUnsub (Subscriber.js:243)
at SafeSubscriber.next (Subscriber.js:190)
at Subscriber._next (Subscriber.js:131)
at Subscriber.next (Subscriber.js:95)
at MapSubscriber._next (map.js:85)
at MapSubscriber.Subscriber.next (Subscriber.js:95)
at XMLHttpRequest.onLoad (http.js:1591)
in the chrome console. (home.component.ts:57):
getBooks() {
const promise = this._homeService.getBooks();
promise.subscribe(
data => {
var jsonObject = data.json();
console.log(jsonObject);
this.books = jsonObject;
},
error => {
console.log(error);
});
}
the line 57 is
var jsonObject = data.json();
can anybody help me please..