Angular4: HttpClient delete request with body

Viewed 5074

I am upgrading my existing Angular2 application to Angular4. I have a delete request which sends body as part of the request like

this.http.delete('/api/deleteAddress', new RequestOptions({
   headers: headers,
   withCredentials: true,
   body: address
}));

New delete function in HttpClient does not have RequestOptions. See function declaration here

Question is how can I make it work with new HttpClient? Should I set it in HttpParams?

2 Answers

(i haven't tested this)

Have you tried adding params?:HttpParams to your delete request options? You have it on the link you've provided.

if that doesn't work then you can just go on with general, request(... method.

this.http.delete('/api/deleteAddress', new RequestOptions({
   method: RequestMethod.Delete,  ====== add this.
   headers: headers,
   withCredentials: true,
   body: address
}));
Related