我正在尝试使用请求库运行lambda函数。我试着看一些其他同样的问题,但找不到我需要的那个。以下是我的代码:
var req = require('request');
var headers = { 'X-AUTH-TOKEN': 'xxxx',
'Content-Type': 'application/json',
'Accept': 'application/json'};
var body = {"name" : "omkarEmailTest", "command_type":"SparkCommand", "language":"notebook", "note_id":"56563", "label":"YetAnotherSparkCluster"};
// Configure the request
var options = {
url: 'http://api.quobole.com/api/v1.2/commands',
method: 'POST',
headers: headers,
body: body,
json: true
};
exports.handler = (event, context, callback) => {
req(options, function (error, response, body) {
console.log(body);
callback(error);
});
}
以下是我在aws lambda控制台中获取的日志:
Response:
{
"errorMessage": "getaddrinfo ENOTFOUND api.quobole.com api.quobole.com:80",
"errorType": "Error",
"stackTrace": [
"errnoException (dns.js:28:10)",
"GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)"
]
}
Request ID:
"2295eee5-ec11-11e7-a9f4-dfa2f9f62b50"
Function Logs:
START RequestId: 2295eee5-ec11-11e7-a9f4-dfa2f9f62b50 Version: $LATEST
2017-12-28T20:53:20.715Z 2295eee5-ec11-11e7-a9f4-dfa2f9f62b50 undefined
2017-12-28T20:53:20.775Z 2295eee5-ec11-11e7-a9f4-dfa2f9f62b50 {"errorMessage":"getaddrinfo ENOTFOUND api.quobole.com api.quobole.com:80","errorType":"Error","stackTrace":["errnoException (dns.js:28:10)","GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)"]}
END RequestId: 2295eee5-ec11-11e7-a9f4-dfa2f9f62b50
REPORT RequestId: 2295eee5-ec11-11e7-a9f4-dfa2f9f62b50 Duration: 655.79 ms Billed Duration: 700 ms Memory Size: 128 MB Max Memory Used: 33 MB
任何帮助将不胜感激!!!!