问题
I'm fairly new to coding and am having issues loading data from the Zomato API with angulars $http. I keep getting invalid API key popping up as an error in my console even though im using the API key generated by Zomato.
Here is a snippet of my code: 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',
}
Please let me know if i'm doing anything wrong or any helpful resources i can use to fix my issue!
Thank you
回答1:
user_key
is not a GET parameter but a header parameter.
You should try this:
$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',
}
});
来源:https://stackoverflow.com/questions/33771792/zomato-api-with-angular