【发布时间】:2017-03-10 14:20:12
【问题描述】:
有人能告诉我如何将下面列出的 curl 代码转换为 Angular js 的 $http.post() 吗?任何帮助将非常感激。谢谢!
curl https://example.zendesk.com/api/v2/organizations.json \
-H "Content-Type: application/json" \
-d '{"organization": {"name": "My Organization"}}' \
-v -u {email_address}/token:{api_token}
到目前为止,我已经设置了以下 angularjs 代码:
$http({
method : "POST",
url : url,
data : angular.toJson($scope.form),
headers : {
'Content-Type' : 'application/json'
}
}).then(Success,Failure);
我只是不知道如何在通话中设置电子邮件地址和令牌。
【问题讨论】:
-
到目前为止,您尝试过什么尝试转换为
$http.post()? -
我已经用我迄今为止尝试过的内容更新了我的问题。
-
你不能也不应该。您真的不想公开您的 api 令牌/密钥。您应该创建一个将转发该信息的后端服务。
-
我设置了一个后端服务,可以在需要时调用 api 令牌,这样不会有太大问题。我现在需要的是转换这个卷曲......
标签: javascript html angularjs curl post