Passing Query parameters to your serverless functions

I will reply myself :slight_smile:

The way I found is using --path option.

When you call the endpoint form the browser you can get the parameter, (in Nodejs) like this: event.pathParameters.parID

if you want to invoke by command line in your local environment and in order to keep the same source code, the way I found is like this: serverless invoke local --function function_name --path lib/data.json
where data.json has the pathParameters parameter value, e.g: {“pathParameters”:{“parID”:“123456”}}

I know is not a very elegant solution but it works, I hope this can help.

Regards,

2 Likes