I am trying to execute the following code in AWS Lambda.
const https = require('https')
var options = {
host: 'http://url',
port: 3000,
path: '/resource?id=foo&bar=baz',
method: 'POST'
};
https.request(options, function(res) {
console.log('STATUS: ' res.statusCode);
console.log('HEADERS: ' JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('BODY: ' chunk);
});
}).end();
But i am getting the following error.
"errorType": "Runtime.HandlerNotFound",
How do i solve this?
CodePudding user response:
When you want to use JavaScript to build a Lambda function, check the AWS SDK for JavaScript Developer Guide for SDK Version 3. There are quite a few step by step tutorials that will answer this question and teach you how to perform this use case.
Start with this:
Invoke a Lambda function from a browser
Make sure that you always read the AWS SDK Guiide (in addition to the Service Guide) when using Lambda and the AWS SDK for JavaScript: