SyntaxError: Unexpected end of input

1,825 views
Skip to first unread message

Adnan Salahuddin

unread,
Jan 19, 2016, 7:16:43 AM1/19/16
to AngularJS
Hi,
I am new angular 2.

Here is i am using Htttp put service.

    this.http.put(window.location.href.split('#')[0] + 'api/vacancy/' + 2, JSON.stringify(updateVacancyValue), { headers: headers }).map(res => res.json()).subscribe(vacancy => this.vacancy = vacancy);

I am getting error message in console (Google Chrome) and it says :

EXCEPTION: SyntaxError: Unexpected end of input

how do i fix it?
I am waiting for your response. Thanks

Luís Loureiro

unread,
Jan 19, 2016, 11:08:36 AM1/19/16
to AngularJS
Hi Adnan!

I think this error might be related with JSON parsing, don't know if JSON.stringify(updateVacancyValue) or res.json().
You could try to console.log both to see if the error is in fact related with JSON parsing.

Regards,
Luís Loureiro

Adnan Salahuddin

unread,
Jan 19, 2016, 11:52:19 PM1/19/16
to AngularJS
if I removed map function and parameter in Subscribe then update (http put service) is working

this.http.put(window.location.href.split('#')[0] + 'api/vacancy/' + 2, JSON.stringify(updateVacancyValue), { headers: headers }).subscribe();

I do not understand of any this.

Adnan Salahuddin

unread,
Jan 20, 2016, 3:21:38 AM1/20/16
to AngularJS
Never Mind! I got it
Thanks :)

Luís Loureiro

unread,
Jan 21, 2016, 6:35:15 AM1/21/16
to AngularJS
Nice to hear that you solved the problem.

Regards,
Luís Loureiro

gulam mohammad

unread,
Apr 12, 2018, 12:15:11 PM4/12/18
to Angular and AngularJS discussion
Even I was facing similar kind of issue and the solution provided has worked like a charm. Thanks for that.

Danish Bhasin

unread,
Jun 9, 2018, 9:31:26 AM6/9/18
to Angular and AngularJS discussion
bro i m also getting the same error Unexpected end of JSON in angular 6...Plzz tell me the solution

Reply all
Reply to author
Forward
0 new messages