0

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

kgandroid
  • 5,507
  • 5
  • 39
  • 69

2 Answers2

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',
    }
});
Henrique B.
  • 450
  • 3
  • 9
  • thanks i'm pretty sure you're right, however chrome is sending an OPTIONS request and Zomato's api doesn't respond to OPTIONS requests so its breaking :( might switch to different api – mnikolic10 Nov 18 '15 at 23:13
  • That's probably related to CORS, not allowing localhost to consume their API. – Henrique B. Nov 19 '15 at 11:40
-1

I Think zomato have ended their API service & No longer the API is running.

But I have made an unofficial Zomato API at here : https://github.com/ripyas/zomato-api

Shajin KP
  • 27
  • 9
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/33316385) – ahuemmer Dec 06 '22 at 08:30