我有这样的功能:
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)
}
正如您所看到的,我正在向DELETE请求(我要删除的建筑物的ID)提供有效负载。但是,有效负载永远不会满足请求。
这是DELETE的正常行为吗?如果是,如何将有效负载添加到DELETE请求?
答案 0 :(得分:1)
HTTP协议允许传递请求体,但是在DELETE的情况下,它没有多大意义。毕竟,它是必须标识您要删除的资源的请求URI。