How to send delete request to REST api using angular?
I want send delete with id: 1
I try:
this.http.delete(environment.apiUrl+"id="+1).subscribe(data => {
});
Where http is private http: HttpClient
, but it not working.
Value of environment.apiUrl is http://localhost/deleteendpoint
This should help:
this.http.delete(this.environment.apiUrl/+1).subscribe(data => {
});
const params = new HttpParams().set('id', '1');
this.http.delete(environment.apiUrl, { params })
.subscribe(
result => console.log(result),
err => console.error(err)
);
Try the above - sorry for poor answer format, on mobile :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.