Search code examples
angularangular4-httpclient

Angular4: HttpClient delete request with body


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?


Solution

  • (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.