使用nodejs连接到Bing API时,HTTPS Get会拒绝连接错误

时间:2017-08-16 02:56:58

标签: node.js amazon-web-services aws-lambda http-get bing-api

我能够使用Chrome扩展程序连接到Bing API端点 - 邮递员 我是NodeJS和AWS Lambda的新手。从AWS Lambda函数连接到nodejs 6.9.0

时看到以下错误
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);
};

感谢您的帮助

1 个答案:

答案 0 :(得分: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);
 });