[英]Zomato api is not working in Nodejs
我需要使用Nodejs中的Zomato Api對特定餐廳進行評論 。但是此api在郵遞員中工作。
但是它在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);
});
根據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.