[英]Zomato api is not working in Nodejs
I need to get the review of a particular restaurant using Zomato Api in Nodejs.But this api is working in postman . 我需要使用Nodejs中的Zomato Api对特定餐厅进行评论 。但是此api在邮递员中工作。
But it is not working in Nodejs . 但是它在Nodejs中不起作用 。
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);
});
As per the documentation of Zomato API you need to use GET
request instead of POST
. 根据Zomato API的文档,您需要使用GET
请求而不是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"}'
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.