[Fixed] Angular Service Delete method

Issue

I am trying to delete a customer using angular services delete method but I don’t know how I can pass id parameter dynamically from the angular component. Can anyone tell me how to pass id dynamically?

deleteCustomerById(id: number): Observable<number>
      {
        const httpOptions =
        {
          headers: new HttpHeaders({ 'Content-Type': 'application/json'})
        };
          return this.http.delete<number>('http://localhost:58274/api/Customers/{id}' + id, httpOptions);
      }

Solution

you are looking for :

 this.http.delete<number>(`http://localhost:58274/api/Customers/${id}`, httpOptions);

Details

Leave a Reply

(*) Required, Your email will not be published