0

I am trying to access zomato api.

URL: https://developers.zomato.com/api/v2.1/categories

Headers: 'X-Zomato-API-Key':'myapikeyhere-763demoapi434'

If I use chrome's postman extension or curl then I can access the url & getting 200 status code.

But if I run it through my angular2 app or simple ajax, it is giving error at preflight OPTIONS request, error code is 501. I have tried otherways too, error is same. Need help

wmnitin
  • 3,387
  • 1
  • 13
  • 19

1 Answers1

3

Zomato API's can only be accessed from server to server calls, the error message you have reported is a security policy implemented by Chrome to prevent cross site request forgery on the client side.

A way you can get around this is to write a handler on your server end to make handler which the ajax call will use, this handler in-turn makes a request to the Zomato's server to retrieve the data required.

Rohit Chandna
  • 251
  • 1
  • 6
  • Thanks able to access via Node, I guess it is because of preflight request that zomato forgot to handle ? – wmnitin Oct 20 '16 at 09:39