我对编码相当陌生,并且在使用 Angular $http 从 Zomato API 加载数据时遇到问题。即使我使用 Zomato 生成的 API key ,我的控制台中仍然不断弹出无效的 API key 错误。
这是我的代码片段:http://jsfiddle.net/3j1c816v/1/
$http({
method: 'GET',
url: 'https://developers.zomato.com/api/v2.1/search?',
params: {
user_id: '', // API key
entity_type: 'city',
q: 'food',
}
如果我做错了什么,或者有任何有用的资源可以用来解决我的问题,请告诉我!
谢谢
最佳答案
user_key
不是 GET 参数,而是 header 参数。
你应该尝试这个:
$http({
method: 'GET',
url: 'https://developers.zomato.com/api/v2.1/search?',
headers: {'user_key' : 'api_key_goes_here'},
params: {
entity_type: 'city',
q: 'food',
}
});
关于javascript - Zomato api 与 Angular ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33771792/