我需要在Nodejs中使用Zomato Api来查看特定餐厅 . 但是这个api正在 postman 中工作 .
但它在 Nodejs 无法正常工作 .
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);
});
1 回答
根据documentation of Zomato API,您需要使用
GET
request而不是POST
.