如何将身体有效载荷传递给有角$ resource DELETE调用 [英] How to pass body payload to angular $resource DELETE call
本文介绍了如何将身体有效载荷传递给有角$ resource DELETE调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经配置了标准的有角度的$ resource
I have standard angular $resource configured as such
angular.module('client.resources')
.factory('ProjectSubjectResource',['$resource',
function ($resource) {
release: {
method: 'DELETE',
isArray: false
}
});
}]);
而我将此方法称为
ProjectSubjectResource.release({projectId: projectId, subjectId: 0},{ subjectIds: subjectIdArray})
其中subjectIdArray是对象数组:
where subjectIdArray is array of objects:
[{subject1: 213123}, {subject2: 3131}]
但是,请求正文不包含该数组.我怀疑DELETE请求是问题所在,例如重命名方法调用PUT有所作为.
However, body of request does not contain that array. I suspect that DELETE request is the problem, as renaming method call to e.g. PUT makes difference.
我可以以某种方式允许DELETE请求的正文吗?
Can I allow body of DELETE request somehow?
推荐答案
deleteSomething: {
method: 'DELETE',
hasBody: true
}
hasBody
-{boolean}
-允许指定是否应将请求正文 是否包含在内.如果未指定,则仅POST,PUT和PATCH请求 将有一个身体.
hasBody
-{boolean}
- allows to specify if a request body should be included or not. If not specified only POST, PUT and PATCH requests will have a body.
这篇关于如何将身体有效载荷传递给有角$ resource DELETE调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文