2015-07-13 32 views
0

嘗試使用$ http.get()方法,並傳遞多個參數implemnt在角JS REST調用,但它拋出 錯誤如何通過在角JS多個參數REST調用

var app = angular.module('angularjs-starter', []); 


    app.controller('MainCtrl', function ($scope, $http) { 


     $http.get("https://api.nexmo.com/verify/json?api_key=56a9bn1af&api_secret=d3n0de241&number=919690286358&brand=stayuncle"); 

    }); 

錯誤是:

org.xml.sax.SAXParseException; lineNumber: 364; columnNumber: 85; The reference to entity "api_secret" must end with the ';' delimiter. 

任何可能的解決辦法?

+1

你應該把它作爲一個對象,它stringfy。 –

+0

@Rohit你好你能改變我的代碼嗎? – nand

回答

1

嗨,你可以嘗試以下,我遠離電腦,所以不能嘗試,並建議肯定。

VAR OBJ = { API_KEY = 56a9bn1af, api_secret = d3n0de241, 數= 919690286358, 品牌= 「stayuncle」 };

$ http.get(「https://api.nexmo.com/verify/json?param=」+ json.stringfy(obj));

從檢查的API,我想你一定要試試這個 -

"https://api.nexmo.com/verify/json?api_key={api_key}&api_secret={api_secret}&number=447525856424&brand=MyApp" 
+0

api期望的參數是什麼?它是你的嗎? –

+0

現在錯誤已經恢復,功能調用沒有發生。在Chrome Web控制檯中獲取此錯誤:未捕獲錯誤:[$ injector:modulerr] :: @line \t var obj = {api_key = 56ab1af,api_secret = d0de241,number = 919600286358,brand =「stayuncle」}; 在Chrome Web控制檯中出現\t錯誤爲「Uncaught SyntaxError:Unexpected token =」。 – nand

+0

其第三方api。這是我試圖實現使用角度js的OTP實現的api。 https://docs.nexmo.com/index.php/verify/verify – nand