ngOnInit() {
this.http.delete('https://jsonplaceholder.typicode.com/posts/1')
.subscribe(() => this.status = 'Delete successful');
}
/** In the Api Service */
/** DELETE: delete the hero from the server */
deleteHero(id: number): Observable<unknown> {
const url = "http://apiurl/" + id; /** DELETE api/heroes/42 */
return this.http.delete(url, httpOptions).pipe();
}
/** In the component */
this.heroesService.deleteHero(hero.id).subscribe();