From AWS documentation: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#invoke-property
JavaScript
x
13
13
1
var params = {
2
FunctionName: 'STRING_VALUE', /* required */
3
ClientContext: 'STRING_VALUE',
4
InvocationType: Event | RequestResponse | DryRun,
5
LogType: None | Tail,
6
Payload: Buffer.from('...') || 'STRING_VALUE',
7
Qualifier: 'STRING_VALUE'
8
};
9
lambda.invoke(params, function(err, data) {
10
if (err) console.log(err, err.stack); // an error occurred
11
else console.log(data); // successful response
12
});
13
How do I specify http method, e.g. GET
, POST
, PUT
, DELETE
when calling lambda.invoke()
?
Advertisement
Answer
lambda.invoke()
invokes the Lambda function – HTTP methods are for invoking Amazon API Gateway routes, not a Lambda function.
A Lambda function just takes in an event.
Either call the Amazon API Gateway endpoint (which then invokes the Lambda), or just directly invoke the Lambda as above.