1
I have the following function in V10.6 nodejs:
#func-1
module.exports.funcOne = (event, context, callback) => {
callback(null, { message: 'funcOne', event });
};
#func-2
module.exports.funcTwo = async (event, context) => {
console.log("value1 = " + event.key1);
console.log("value2 = " + event.key2);
return 'some success message';
};
When I turn the remote on the terminal: sls invoke local --function funcOne
have the answer:
{
"message": "funcOne",
"event": ""
}
And when I turn the remote sls invoke local --function funcTwo
have the answer:
value1 = undefined
value2 = undefined
I can’t see some success message
;
I’m following the documentation of the AWS for lambda functions and Nodejs trying to understand asynchronous functions with callbacks.
Could someone explain why I don’t see the string in the second example?
So, I can’t tell you with 100% certainty if this is it, but from my experience with JS, when you use async, for you to have the output of the function that returns an async, you need to use await, so if you were to call this function normally, you would use Let x = await funcTwo(), for example, and x would return it. I don’t know if that’s the case, but..
– Thiago Salvatore