我想要完成的目标是在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' } );