djangoangulardjango-rest-frameworkweb-development-serverangular-fullstack

I am deleting the object from my database using delete button made in angular 13, but this does not delete it instantly from frontend


i need to delete the object real-time from frontend as well as backend my, The object gets deleted from the backend instantly but it do not reflects in the frontend till the page is refreshed

//delete component

deleteStory(id : string){
  console.log(id)
  this.storyapiService.deleteStory(id).subscribe();
  

  }

service.ts

deleteStory(id: string): Observable<number>{

     return this.http.delete<number>(this.API_URL +id);

  }

//html

<button class="btn btn-primary" (click)="deleteStory(story.id)" style="margin-left:5px">Delete </button>


Solution

  • Try to get data again once you delete the element to refresh the current view.

    Hope it works!