net::ERR_EMPTY_RESPONSE error on DELETE Method in Angular 4?

I am using below method to delete data

return this.http.delete(this.ApiURL, new RequestOptions({headers: headers,body: body }))
.map((res: Response) => res.json());

But got net:: ERR_EMPTY_RESPONSE Also when I run this in POSTMAN it is successfully deleted.

Please guide

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
Jason Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Jason
Guest

In your case the server returns an empty HTTP response body and status 200 OK. However, HttpResponse‘s .json() method expects the body to be a valid JSON string. Since you don’t have a body, the .json() method throws a Unexpected end of JSON input error. You also don’t have a .catch() and this unhandled error propagates to the browser console. One way to solve this is if you have access to the server side code. You can change your DELETE method’s success response status code to be 204 (“No content”). In this way the .json() method will not throw an… Read more »