how to use http delete by name in angular

Viewed 29

I know how http.delete() works. I know it takes url+id but in my case I have JSON server that contains file that has object with no id like this

{
  "name":"anyname",
  "data":"anydata"
}

I know that the name will always be unique so no need for me to give an id for this object. My problem here that I want to delete this object using http.delete() but I also know in order to delete something it needs the url+id like this

deleteAnimal(id:number){
    return this.http.delete(`${environment.rootAnimalslink}/${id}`)
  }

so is there's a way to delete this object by its name other than creating id for each object?

I tried this:

deleteAnimal(name:string){
    return this.http.delete(`${environment.rootAnimalslink}?Name=${name}`)
  }

but it didn't work.

1 Answers

It doesn't have to be an id in the URL.

Related