【发布时间】:2016-07-02 07:35:18
【问题描述】:
我需要在 Nodejs 中使用 Zomato Api 获取特定餐厅的评论。但是这个 api 在 postman 中工作。
但它在 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);
});
【问题讨论】:
标签: javascript node.js express request zomato-api