如何在angularjs中使用curl命令

时间:2016-02-26 12:40:39

标签: angularjs ionic-framework

curl -i -u account_id:api_key“https://xecdapi.xe.com/v1/account_info/

我想在angularjs中使用上面的curl命令。我尝试通过包括标题,但我没有得到任何结果。谢谢提前强文 我想在angularjs中使用上面的curl命令。我尝试通过包括标题,但我没有得到任何结果。谢谢提前强文 我想在angularjs中使用上面的curl命令。我尝试了包括标题,但我没有得到任何结果。谢谢提前强文

2 个答案:

答案 0 :(得分:0)

你不能。您应该使用angular中的http服务来发送请求。 First article from google

 $http.get('https://xecdapi.xe.com/v1/account_info/', {
        headers: {"Authorization": "Basic account_id:api_key"})
        .success(function(response){
        console.log(response)
      })

答案 1 :(得分:0)

Curl和Wget - 这些是系统级令牌。你不能在Angular环境中使用它们。

尝试$ http方法或使用$ resource指令进行REST调用。