Restangular - PUT请求负载正在发送的查询字符串参数 [英] Restangular - PUT request payload is being sent as query string parameters

查看:426
本文介绍了Restangular - PUT请求负载正在发送的查询字符串参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm using rectangular and have something like this:

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

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

Now, when the request is sent, my "stuff" object is being sent in the query string instead of the body!

什么我是我做错了?

推荐答案

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

What you want to do here is use customPUT() instead of the normal put().

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

从文档


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

  • put([queryParams, headers]): Does a put to the current element

customPUT([ELEM,路径,参数,头):难道一个付诸具体路径。您也可以选择设置PARAMS和头部和元素。 ELEM是张贴的元素。如果它没有设置,它假定它是从哪个你调用这个函数的元素本身。

customPUT([elem, path, params, headers]): Does a PUT to the specific path. Optionally you can set params and headers and elem. Elem is the element to post. If it's not set, it's assumed that it's the element itself from which you're calling this function.

这篇关于Restangular - PUT请求负载正在发送的查询字符串参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆