gpt4 book ai didi

angularjs - restAngular 使用方法 customPOST。文本 :[object%20Object] is getting added on to the end of URL

转载 作者:行者123 更新时间:2023-12-03 08:20:49 25 4
gpt4 key购买 nike

我要实现的目标是在 restAngular 中发帖。我一直在尝试下面的代码,但是我收到一个带有 customPost 的状态代码 400。这是我将请求发送到的 URL...http://localhost/api/api/index.php/auth/token/[object%20Object]。如您所见,[object%20Object] 正在添加。我该如何摆脱这个?除了 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', username:'b@t.com', password:'666666', scope:'app'},
'token',
{},
{
Authorization:'Basic ' + client,
ContentType:'application/x-www-form-urlencoded'
}
);

关于angularjs - restAngular 使用方法 customPOST。文本 :[object%20Object] is getting added on to the end of URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19798632/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com