I\'m working on a aws serverless project and need to test the lambda functions locally.
I am using serverless invoke local -f {function_name} command to te
I've tried the answers with the attribute --data but neither works.
In fact the problem is that the --data will pass a string value to the framework. So if you write in your javascript file:console.log(typeof(event));, you will get String instead of Object. Which means serverless framework doesn't transform the input to a JSON object correctly. That's why you got xx of undefined error.
My solution is to use the -p(or --path) attribute. In your example, follow these steps:
{"pathParameters":{"food_id":"100"}}food_id, use event.pathParameters.food_idsls invoke local -f yourFunction -p test.json