@control-c-io/mylambda
v1.1.0
Published
When using this modules for both *invokeLmabda* and *invokeLambdaEvent* the keyword `await` must be used.
Downloads
4
Readme
Use await with these functions
When using this modules for both invokeLmabda and invokeLambdaEvent the keyword await
must be used.
Although the second one is an event based (async) which immediatly returns (statusCode: 202 with empty payload), if you don't await on this invokation while being used the handler of the function might returned and process gets exited before invokation.
Use invokeLambdaEvent only when don't require response form the second function and it acts like a trigger.
Sample Use case
We want to invoke echo function and get some result from it and return to user. This is inside current (1st) function
var mylambda = require('mylambda')
.
.
.
exports.handler = async (event) => {
let result = await mylambda.invokeLambda("xxxx-echo",event)
return {
statusCode: 200,
body: JSON.stringify(result.body)
}
}
We want to invoke echo function and get some result from it and return to user. This is inside current (1st) function
var mylambda = require('mylambda')
.
.
.
exports.handler = async (event) => {
let result = await mylambda.invokeLambdaEvent("xxxx-echo",event)
return {
statusCode: 200,
body: "Echo function Triggered(hopefully 😁)"
}
}