-->

Restangular - PUT请求有效载荷被发送作为查询字符串参数(Restangular

2019-10-23 06:26发布

我使用矩形和有这样的事情:

stuffResource = parentResource
          .one(resources.category, $scope.stuff.category)
          .one(resources.stuff, $scope.stuff.id)
          .put($scope.stuff);

现在,当请求被发送,我的“东西”对象被查询字符串,而不是身体发!

什么我我做错了什么?

Answer 1:

什么你想在这里做的是使用customPUT(),而不是普通的put()。

stuffResource = parentResource
    .one(resources.category, $scope.stuff.category)
    .one(resources.stuff, $scope.stuff.id)
    .customPUT($scope.stuff);

从文档

  • 放([queryParams,标头]):是否看跌当前元素

  • customPUT([ELEM,路径,参数,头]):是否一个PUT到的特定路径。 您也可以选择设置PARAMS和头部和元素。 ELEM是张贴的元素。 如果它没有设置,它假定它的元素本身要从中调用这个函数。



文章来源: Restangular - PUT request payload is being sent as query string parameters