I am working on an angular2 project. I am stuck with these errors. The error occured when I tried to send the JSON objects to the backend. It may be due the parsing of JSON obje
Thanks @Jacob Krall for pointing out the reason:
I was getting the same error for following code
this.http.post(URL, formData).map((res: Response) => res.json()).subscribe(
(success) => {
alert(success);
},
(error) => alert(error))
Reason: I was not sending json data from server itself so it was crashing for line res.json()
Solution: Return json response from server then it should work fine.
replaced the following
return res.send("Upload Completed for " + path);
with,
return res.json("Upload Completed for " + path);