2017-02-16 110 views
0

我正在向外部API發送HTTP請求,但無法弄清楚如何訪問其內部主體。所有的節目都在Lambda上進行。AWS Lambda:如何訪問HTTP請求屬性

例如:

https.get(url, function(res) { 
    console.log(res); 
}); 

我知道怎麼去res.headers,如何讓res.statusCode,如何讓res.status等,但不知道如何獲得數據,我需要。 console.log(res)不給我我想要的東西,就像下面廢話:

enter image description here

+0

您是否嘗試過'res.body'?另外,在你的例子中,這將有助於瞭解什麼是「https」,也就是你正在使用哪個庫。 – kulesa

回答

0

我發現here

https.get(url, function(res) { 
    res.on('data', function (chunk) { 
    console.log(JSON.parse(chunk.toString()); 
});