使用Restangular PUT/GET和Payload

Moh*_*han 14 angularjs restangular

我在我的一部作品中使用了Restangular

服务器人员给了我以下调用,我需要在AngularJS客户端上集成

  1. PUT api/partners/password - RequestPayload [{password,confirmpassword}]合作伙伴ID正在标题中发送

  2. GET api/partners/password/forgot/ - 请求Payload [{emailaddress}]合作伙伴ID正在标题中发送

我为调用这些服务而编写的javascript代码如下

  1. Restangular.all( '合作伙伴')一个( '密码')把(PARAMS). - 将params作为查询字符串发送
  2. Restangular.all( '合作伙伴')一个( '密码')一个( '忘记')得到(PARAMS).; - 在网址中发送对象

我尝试了其他方法,但它根本没有拨打正确的电话.

帮帮我们!

mgo*_*nto 22

所以,对于第一点.它把对象放在手边,而不是另一个对象.所以你有两个选择:

选项1

var passReq = Restangular.all('Partners').one('Password');
passReq.confirmPassword = ....
passReq.put(); // confirmPassword and the params of the object will be sent 
Run Code Online (Sandbox Code Playgroud)

选项2是

var passReq = Restangular.all('Partners').one('Password').customPUT(obj);
Run Code Online (Sandbox Code Playgroud)

对于Point#2,您不能在GET中发送请求正文(有效负载).

  • 为什么patch函数接受一个对象而不是put函数.看起来有点不协调. (2认同)