angularjs – restAngular使用方法customPOST. text:[object Ob
发布时间:2020-12-17 17:48:43 所属栏目:安全 来源:网络整理
导读:我想要完成的目标是在restAngular中做一个帖子.我一直在尝试下面的代码,但是我收到了一个带有customPost的状态代码400.这是我发送请求的URL … http://localhost/api/api/index.php/auth/token/ [object Object].如您所见,[object Object]是gettting添加的.
我想要完成的目标是在restAngular中做一个帖子.我一直在尝试下面的代码,但是我收到了一个带有customPost的状态代码400.这是我发送请求的URL … http://localhost/api/api/index.php/auth/token/ [object Object].如您所见,[object Object]是gettting添加的.我怎么摆脱这个?我应该在customPOST之外做另一种方法吗?为什么要添加这个?
var login = Restangular.one('auth/token').customPOST( {grant_type:"password",username:"b@t.com",password:"666666",scope:"app"},{},{Authorization:'Basic ' + client,ContentType:'application/x-www-form-urlencoded'}); 解决方法
customPOST的第二个参数应该是表示路径的字符串.试试这个:
var login = Restangular.one('auth/token').customPOST( {grant_type:'password',username:'b@t.com',password:'666666',scope:'app'},'',{ Authorization:'Basic ' + client,ContentType:'application/x-www-form-urlencoded' } ); 或这个: var login = Restangular.one('auth').customPOST( {grant_type:'password','token',ContentType:'application/x-www-form-urlencoded' } ); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |