Passing API Key from one Query to Another

I have a query ("fetchKey") that returns my API key using a POST. The query is correctly returning the value of the API key.

I want to store this as a variable that can be used by retool in other queries. So I created a hidden text input component called tokenHolder and I can see that the API key is successfully stored here.

image

Now I want to take this key and use it in other queries. When I tried passing it to another query, I first tried to call it this way:

image

However, this gives me the error "wrapping code in {{ }} is not supported here"

So, then I tried this:
image

And similarly, Retool gives me a warning that "tokenHolder" is not defined on this line: const token = tokenHolder.value;

And then I tried:
const token = utils.getValue("tokenHolder"); // Retrieve the token from the tokenHolder component

But retool doesn't recognize "utils.getValue" as a valid function.

Hi @emkay_ventures,

Javascript queries don't need double curlies, so you'll get past that error by changing 'Bearer {{tokenHolder.value}}' to "Bearer " + tokenHolder.value, (no need to wrap in an additional set of quotes). In the second screenshot, you could use "Bearer " + token ,

Usually, the best practice is to move all of this logic to a custom api authentication set up instead of handling it in Javascript queries. Would this work for your use case?