Home > database >  Delete Button not working with json server using angularjs
Delete Button not working with json server using angularjs

Time:03-22

I am doing angular crud operation using JSON server, post and get are working properly but delete is not working DELETE /posts1 404. My code is as follows -

deleteEmployee(id : number){
    return this.http.delete<any>("http://localhost:3000/posts" id)
    .pipe(map((res:any)=>{
      return res;
    })

DELETE http://localhost:3000/posts1 404 (Not Found)

CodePudding user response:

fix url

 return this.http.delete<any>("http://localhost:3000/posts/" id)

or maybe

 return this.http.delete<any>("http://localhost:3000/posts?id=" id)
  • Related