1

I have a function like this:

async deleteBuilding ({ commit, state }, payload) {
  const urlEnd = '/v1/building/update'
  const type = 'delete'
  const resp = await api.asyncRequest(urlEnd, type, payload)
  commit('DELETE_BUILDING', resp.data)
  return resp
},

api.asyncRequest = async (urlEnd, type, payload = {}) => {
  return await Vue.http[type](api.serverUrl + urlEnd, payload, timeout)
}

As you can see, I'm feeding a payload to the DELETE request (the ID of the building that I want to delete). However, the payload never makes it to the request.

Is this DELETE's normal behavior? If so, how to add a payload to a DELETE request?

alex
  • 7,111
  • 15
  • 50
  • 77
  • 1
    have you checked others' questions? http://stackoverflow.com/questions/299628/is-an-entity-body-allowed-for-an-http-delete-request – andrusieczko Apr 25 '17 at 02:44

1 Answers1

1

The HTTP protocol allows to pass a request body, but in case of DELETE it doesn't make a lot of sense. After all it's the request URI that must identify the resource you want to delete.

Julian Reschke
  • 40,156
  • 8
  • 95
  • 98