https://linen.dev logo
Title
a

Alex P

03/20/2023, 7:43 PM
Hi! I am trying to use the form data of a request in the response. The request body looks like this
flag1[enabled]=true&transfer[destination]=target_account&metadata[userId]=1-2-3-4&metadata[sessionId]=a-b-c
I am having a hard time to use the values in the response. I am parsing the form via
{{formData request.body 'params' urlDecode=true}}
and I can see the values fine when doing
{{#each params}}
{{@index}} - {{@key}} - {{this}}
{{/each}}
But I cannot access the individual fields, no matter what I try, e.g.,
{{"metadata[userId]"}}
{{metadata\[userId\]}}
{{metadata.userId}}
My Google-fu also failed me 😕
Not sure how applicable it is, but it does work on http://tryhandlebarsjs.com/
t

Tom

03/20/2023, 8:16 PM
Hi @Alex P, square brackets seem to be an issue for this implementation of Handlebars, but there’s a solution which is to use the
lookup
helper e.g.
{{lookup params 'transfer[destination]'}}
🙌 1
a

Alex P

03/21/2023, 8:35 AM
I thought I tried that as well but it seems I needed to sleep over this. This works! Thanks a lot!
👍 1