I think I can simplify my expected outcome down to:
As a Retool app builder, I would like to dynamically set which header and payload values to send my API/query request based on a specific button that my Retool app users clicked in the Retool app.
Why: depending on which button the user clicked (even if it's to invoke the same end-query resource), we want to send a specific payload/param request, and we want to log a certain value in one of our custom headers so we have additional usage context in the future for which buttons users are using to submit requests.
I have several buttons on an app page that effectively call the same query resource. However I would like to dynamically pass in (via a single transformer ideally) a specific endpoint param and header value based on which button was clicked. if this was a vanilla html/js app, I would basically inspect the handled event and use that to inform the payload/headers sent to the fetch/request. Does Retool support a similar kind of approach?
What I have tried
- For the longest time I was using this approach that was suggested in this thread a few months back:
However, this ended up creating unexpected behavior in the app (bugs) and confused both my users and myself when I tried to debug - because the outcome is driven if the table has data populated, and if it does and the user tries to use one of those buttons, my transformer overrides it in effect
I am using two different
JS Query resources that each button is specifically mapped to. This is ok, but ideally it would be much easier if I could just 'inspect the event emission source' (eg name or id of the button ) in a
transformer and then based on that value, determine the values passed into my query resource