2

I want to include a DELETE request in my angular application. GET and POST works perfect.

Please find the important part of my user.service.ts file below:

deleteMethod(a: A): Promise<any> {
  return this.http.delete(this.apiURL, a)
    .toPromise()
    .catch(this.handleError);
}

If I call the request, I get the following error:

TypeError: options.search.clone is not a function.

Do you have any ideas how to solve it?

Thank you very much for your help!

AT82
  • 71,416
  • 24
  • 140
  • 167
CodingMole
  • 53
  • 6
  • can you post the 'a' variable values? ie http options – Sreemat Aug 06 '17 at 17:40
  • Is `a` suppose to be `RequestOptionsArgs`? – Nehal Aug 06 '17 at 18:24
  • You should pass `RequestOptionsArgs` as a parameter into your `delete` method. What is the type of `a`, actually what is `A`? – ulubeyn Aug 06 '17 at 18:27
  • Thank you guys for your answers. `A` referes to a typescript file which defines the structure as the following example: `export class Device { hello: string; constructor(userObj) { this.hello= userObj.hello; } }` For that, I guess, I already defined the `RequestOptionsArgs`, right? What could I do else? THANKS A LOT ;-) – CodingMole Aug 06 '17 at 21:39
  • What is your purpose of passing `a` as a parameter into `delete` method? – ulubeyn Aug 07 '17 at 10:43
  • With `a`, I send some information through the `delete` method that the backend knows which entity it should remove. – CodingMole Aug 07 '17 at 13:00
  • Possible duplicate of [Body of Http.DELETE request in Angular2](https://stackoverflow.com/questions/38819336/body-of-http-delete-request-in-angular2) – Steffen Schmitz Aug 14 '17 at 09:23
  • Thank you for sharing this amazing solution ;-) – CodingMole Aug 14 '17 at 09:24
  • 1
    See this answer for adding the body to the options object: https://stackoverflow.com/a/40857437/6059889 – Steffen Schmitz Aug 14 '17 at 09:25

0 Answers0