0

I need to get the review of a particular restaurant using Zomato Api in Nodejs.But this api is working in postman .

postman response

But it is not working in Nodejs.

Nodejs response app.js

var https = require('https');
var request = require('request');
var zomatoUserKey = '****************************';
var postheaders = {
  'Content-Type': 'application/json; charset=utf-8',
  'user-key': zomatoUserKey
};
var optionspost = {
  host: 'developers.zomato.com', // here only the domain name
  path: 'api/v2.1/reviews', // the rest of the url with parameters if needed
  headers: postheaders,
  method: 'POST',
  data: '{"res_id": "zoma.to/r/34343"}'
};
https.request(optionspost, function(error, response, body) {
  console.log('error', error);
  console.log('body', body);
  console.log('response', response);
});
Muhsin Keloth
  • 7,855
  • 7
  • 39
  • 59

1 Answers1

0

As per the documentation of Zomato API you need to use GET request instead of POST.

var optionspost = {
  host: 'developers.zomato.com', // here only the domain name
  path: '/api/v2.1/reviews', // the rest of the url with parameters if needed
  headers: postheaders,
  method: 'GET',
  // -------^----
  data: '{"res_id": "zoma.to/r/34343"}'
};
Pranav C Balan
  • 113,687
  • 23
  • 165
  • 188