2017-04-25 69 views
1

我有这样的功能:是否可以将一个主体有效载荷提供给DELETE请求?

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) 
} 

正如你所看到的,我喂有效载荷删除请求(即我想删除建筑物的ID)。但是,有效负载永远不会满足请求。

这是DELETE的正常行为吗?如果是这样,如何将有效载荷添加到DELETE请求?

+1

你检查了别人的问题吗? http://stackoverflow.com/questions/299628/is-an-entity-body-allowed-for-an-http-delete-request – andrusieczko

回答

1

HTTP协议允许传递一个请求体,但是在DELETE的情况下它没有什么意义。毕竟它是请求URI必须标识你想要删除的资源。

相关问题