jashkenas / backbone

Give your JS App some Backbone with Models, Views, Collections, and Events
http://backbonejs.org
MIT License
28.09k stars 5.39k forks source link

Model.destoy should allow to set a body #4231

Closed fabianfrz closed 4 years ago

fabianfrz commented 4 years ago

A delete request may have a body containing some meta data like who deletes the resource and why. This information is usually not required for the delete process itself but may be required for the process (usually documentation purposes).

For example:

model.destroy({
    data: {
       reason: "Deleted due to GDPR delete request"
   }
});
DELETE /resouces/1 HTTP/1.0
Host: example.com
Content-Type: application/json
Content-Length: xxx

{
  "reason": "Deleted due to GDPR delete request"
}
paulfalgout commented 4 years ago

This is the current API for backbone. Granted you may need to JSON.stringify data and/or set your contentType, but doing exactly what you're doing in the code above works in backbone.

fabianfrz commented 4 years ago

Thanks, I will think if I will document that in the Backbone.sync section.