Skip to content

Conversation

Sk-Azraf-Sami
Copy link

Fix: Remove body from DELETE request in deleteTodo mutation

Problem

The previous implementation of the deleteTodo mutation included a body in the DELETE request:

deleteTodo: builder.mutation({
  query: ({ id }) => ({
    url: `/todos/${id}`,
    method: 'DELETE',
    body: id
  }),
  invalidatesTags: ['Todos']
}),

Including a body in a DELETE request caused the API to fail to delete items from the todo list. As a result, the delete operation did not work as expected.
A video demonstrating this issue is attached.

Solution

This PR removes the unnecessary body property from the DELETE request:

deleteTodo: builder.mutation({
  query: ({ id }) => ({
    url: `/todos/${id}`,
    method: 'DELETE',
  }),
  invalidatesTags: ['Todos']
}),

Impact

  • The delete operation now works correctly, and todos can be deleted as expected.
  • No breaking changes to other endpoints.

Additional Info

  • Video attached showing the issue before this fix.
bug-demonstration.mp4

Tested: Manually tested delete functionality after the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant