How to add a body to Angular HttpClient delete function

Hongyang Du picture Hongyang Du · Sep 5, 2017 · Viewed 37.5k times · Source

Our project is migrating to Angular4, and use @angular/common/http Httpclient as the default network tool. But I found there are no body params in delete function. How do I add the body to delete function? Thanks.

Answer

Andrii Ivanyk picture Andrii Ivanyk · Sep 20, 2017

You may use a universal request method on the HttpClient class instead. This method has the body in options. https://angular.io/api/common/http/HttpClient#members

e.g this.http.request('delete', 'url', { body: ... })