You need to configure the mapping template in the Gateway API. If you know the name of your parameters in advance, your template may look like this:
{ "userId": "$input.params('userId')", "limit": "$input.params('limit')", "offset": "$input.params('offset')" }
Where each $input.params('...') will be evaluated, and the value in your query string will be put in its place when the event is sent to Lambda.
If you do not know the parameter names in advance, you will need to parse in Lambda. Your pattern matching will look like this:
{ "querystring": "$input.params().querystring" }
In the end, it will look like the one shown in Lambda:
{ "querystring": "{limit=25, offset=0, userId=212733}" }
And then you will parse event.querystring instead of window.location.search in getParam() . Obviously, you will need to change some of the logic, since you will be sharing commas, not ampersands, and you will need to get rid of curly braces. By the way, since you are on the server at the moment you do not have a window object.
source share