It's actually the first time that I'm trying to call a delete method angular. my code in my dataService is:
deleteMeaningItem(data): Observable<Result> {
return this.http.delete<Result>(url, data);
}
and in component:
this.dataService.deleteMeaningItem({id: id}).subscribe(res => {
if (res.status) {
//do something
}
});
but I'm getting 415 Unsupported Media Type error! I've also tried to send Content-Type in my request header like:
deleteMeaningItem(data): Observable<Result> {
return this.http.delete<Result>(global.dataUrl + '/MeaningItems/Delete', { params: data,
headers: {'Content-Type': 'application/json'}});
}
but then then I'm getting 400 Bad Request error! I need your help.
all I had to do was to provide body in the request option. so I did this:
deleteMeaningItem(meaningId): Observable<Result> {
const options = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
}),
body: meaningId,
};
return this.http.delete<Result>(global.dataUrl + '/MeaningItems/Delete', options);
}