aixigo / hal-http-client

A status code driven JSON HAL HTTP client based on the fetch API.
MIT License
3 stars 2 forks source link

`del` (DELETE requests) should support a request body #19

Closed alex3683 closed 6 years ago

alex3683 commented 6 years ago

Currently the methods get(), head() and del(ete)() do not support a request body. While this is okay for HTTP GET and HEAD requests, a DELETE request can carry a meaningful body. For example we currently have a use case, where the deletion of a resource should be accompanied by a comment from the person deleting it. This change will be breaking, as the options argument will get shifted.

alex3683 commented 6 years ago

Implemented on master (v0.9.0).

Breaking Change

The del method (or its alias version delete) now supports a data for the request body as second argument. This shifts the options argument from position two to three in the arguments list. Hence, if only options and no data should be passed to del, simple use undefined as second argument:

hal.del( theUrl, undefined, myOptions );