A J Qarshi
A J Qarshi

Reputation: 2992

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?

Upvotes: 2

Views: 5156

Answers (2)

Ravindra Gupta
Ravindra Gupta

Reputation: 91

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

Upvotes: 0

tlt
tlt

Reputation: 15301

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

Upvotes: 2

Related Questions