【问题标题】:HTTPS Get gives connection refused error while connecting to Bing API using nodejsHTTPS Get 在使用 nodejs 连接到 Bing API 时出现连接被拒绝错误
【发布时间】:2017-08-16 02:56:57
【问题描述】:

我能够使用 Chrome 扩展程序 - Postman 连接到 Bing API 端点。
我是 NodeJS 和 AWS Lambda 的新手。从带有 nodejs 6.9.0 的 AWS Lambda 函数连接时看到以下错误

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

感谢您的帮助

【问题讨论】:

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


    【解决方案1】:

    您可能需要并使用包 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);
     });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-01
      • 2019-01-12
      • 1970-01-01
      相关资源
      最近更新 更多