2017-08-16 45 views
0

我能夠使用Chrome擴展程序 - 郵遞員連接到Bing API端點。
我是NodeJS和AWS Lambda的新手。看到下面的錯誤,而從AWS lambda函數與連接6.9.0的NodeJSHTTPS在使用nodejs連接到Bing API時獲取連接拒絕錯誤

Error: connect ECONNREFUSED 127.0.0.1:443 
at Object.exports._errnoException (util.js:1018:11) 
at exports._exceptionWithHostPort (util.js:1041:20) 
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14) 

Code: 

exports.handler = (event, context, callback) => { 
var headers = { 
'Ocp-Apim-Subscription-Key': '******************', 
'Content-Type': 'application/json', 
}; 
var options = { 
url: 'https://api.cognitive.microsoft.com/bing/v5.0/search?     
&q=hello', 
method: 'GET', 
headers: headers, 
}; 
const https = require("https"); 
https.get(options); 
}; 

感謝您的幫助

回答

0

您可能需要並使用包node-bing-api使用Bing API來搜索。

var Bing = require('node-bing-api')({ accKey: "your-account-key" }); 

Bing.web("hello", function(error, res, body){ 
    console.log(body); 
}); 
+0

謝謝!這樣可行! – user08152017