I\'m trying to talk to a somewhat RESTful API from an Angular 2 frontend.
To remove some item from a collection, I need to send some other data in addition to the re
Since the deprecation of RequestOptions, sending data as body in a DELETE request is not supported.
If you look at the definition of DELETE, it looks like this:
delete(url: string, options?: {
headers?: HttpHeaders | {
[header: string]: string | string[];
};
observe?: 'body';
params?: HttpParams | {
[param: string]: string | string[];
};
reportProgress?: boolean;
responseType?: 'json';
withCredentials?: boolean;
}): Observable;
You can send payload along with the DELETE request as part of the params in the options object as follows:
this.http.delete('http://testAPI:3000/stuff', { params: {
data: yourData
}).subscribe((data)=>.
{console.log(data)});
However, note that params only accept data as string or string[] so you will not be able to send your own interface data unless you stringify it.