amplify-js icon indicating copy to clipboard operation
amplify-js copied to clipboard

Accept "body" on delete API

Open dorin-moldoveanu-assist opened this issue 1 year ago • 9 comments

Is this related to a new or existing framework?

React

Is this related to a new or existing API?

REST API

Is this related to another service?

No response

Describe the feature you'd like to request

Using the API, del function more accurately, I would like to be able to send the body on a DELETE request. Currently this is prohibited ( line 6 )

Screenshot from 2024-01-12 17-50-00

Describe the solution you'd like

I would like the DeleteInput type to match any other type like GetInput, PostInput etc

Describe alternatives you've considered

Tried to create a separate type definitions file, to overwrite current definitions from the library but without luck.

Additional context

No response

Is this something that you'd be interested in working on?

  • [ ] 👋 I may be able to implement this feature request
  • [ ] ⚠️ This feature might incur a breaking change

dorin-moldoveanu-assist avatar Jan 12 '24 16:01 dorin-moldoveanu-assist

Hello, @dorin-moldoveanu-assist and thank you for creating this issue. It seems you're correct that the DeleteInput type is not consistent with GetInput and PostInput types for example, and doesn't allow for any body to be included. I'll review this feature request with the team internally, but maybe you can provide some additional context. Can you describe in a little more detail the use case and need for the body to be included for this? Is it due to a requirement for an API you're using/built?

cwomack avatar Jan 12 '24 18:01 cwomack

Hey @cwomack, sure thing.

Going to give a little bit of context/example for a better understanding. I have a /users endpoint and based on REST best practices, when you wish to delete one user, you will send a DELETE request to /users/{userId} ( no body necessary ). On the same note, if you wish to delete all users, you will send a DELETE request to /users ( no body necessary ). In my case, I would like to delete a specific number of users, hence I would like to send a DELETE request to /users and inside it's body a list of user ids.

Hope the provided information is helpful and a nice reason to accept the body on delete requests. Thanks!

dorin-moldoveanu-assist avatar Jan 13 '24 21:01 dorin-moldoveanu-assist

We also encountered the same business requirements, we hope that DELETE can pass parameters through the body

tuskermanshu avatar Feb 20 '24 02:02 tuskermanshu

Hello everyone. I too think that the DELETE method should be able to have a BODY.

According to MDN, the DELETE method can have a BODY. https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE

nyamairi avatar Jun 14 '24 05:06 nyamairi

Hi all, I too share the same opinion, as It would be nice to have this feature on the project I am currently working on.

paulolopesrb avatar Jun 27 '24 10:06 paulolopesrb

It also can have response body, which also isn't currently possible for DELETE API

TomasChmelik avatar Aug 07 '24 07:08 TomasChmelik

I would like to use a body on the del method as well. What is the status of this issue?

ben-gryps avatar Aug 08 '24 18:08 ben-gryps