2017-08-16 5 views
0

J'ai pu me connecter au point de terminaison de l'API Bing en utilisant l'extension Chrome - Postman.
Je suis nouveau sur NodeJS et AWS Lambda. En voyant l'erreur ci-dessous lors de la connexion d'une fonction Lambda AWS avec nodejs 6.9.0HTTPS Get donne une erreur de connexion refusée lors de la connexion à l'API Bing en utilisant nodejs

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

apprécions votre aide

Répondre

0

Vous pourriez avoir besoin et utiliser le package node-bing-api pour rechercher avec Bing Api.

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

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

Merci! Ça marche! – user08152017