I have a AWS Gateway API that defines a simple GET. I use that to trigger a Lambda. Using the request mapping i take the query params and create a json object to give the Lambda. Here is my mapping
#set ($myMap = $input.params().get("querystring"))
{
#foreach($paramName in $myMap.keySet() )
"$paramName" : "$util.escapeJavaScript($myMap.get($paramName))"
#if($foreach.hasNext),#end
#end
}
I am new to VTL and Amazon Gateway API and it seems i am making a mistake that is cause this to never complete. I have tried many variations but if i ever quote $myMap.get($key)
it wont complete. What am i doing wrong? Id love to understand. Suggestion for same output also welcome.
UPDATE
If i remove the "{" and "}" this no longer times out! Now i dont know why that matters and it is not the format i want at all but interesting tidbit to get to the bottom of this.
Update 2
Simplified the logic and its reflected above with the same issue. I also found that if put an attribute in the json that opens another object the logic works. This is terrible.
{
"data": {
#foreach($paramName in $myMap.keySet() )
"$paramName" : "$util.escapeJavaScript($myMap.get($paramName))"
#if($foreach.hasNext),#end
#end
}
}