2016-07-02 6 views
0

ノードジでZomato Apiを使用して特定のレストランのレビューを取得する必要がありますが、このAPIはのpostmanで動作しています。Zomato APIがNodejsで動作していません

postman response

しかし、それは、Nodejsで働いていません。あなたの代わりにPOSTGET要求を使用する必要がdocumentation of Zomato APIあたりとして

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); 
}); 

答えて

0

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"}' 
}; 
関連する問題