I'm trying to create an chain of api-calls (get data out of Supabase, call PDFMonkey to create PDF, call PDFMonkey to get the shared URL, upload to google Drive, add URL to Supabase) .
At the moment I'm chaining via the 'on Succes Trigger', but this results in a lof of queries, losing sight which query is triggered when and why. Is there a better, more clear way, to do this?
Very common problem in Retool. This is a good post that describes the pattern I use for that. In fact I use this quite a lot.
Thanks for the above, v helpful.
One question, when triggering your example from another JavaScript query, how can I run something only if the trigger succeeds and is completed?
For example, if your code above is in a query called `triggerManyAsyncsExample', and I want to run it from another query and console log after it's finished how could I achieve that?
I attempted this with the code below, but it runs the code after triggerManyAsyncsExample.trigger() immediately regardless of the outcom…
You can get more advanced my return values from one javascript query to another:
Encountered this one today which has me puzzled.
I have a js query using the async pattern:
(async () => {
const data1 = await jsTranslateRouteToLines.trigger()
const data2 = await qryUpdateRouteLines.trigger({additionalScope: {index: selFilterLeg.value, lines: data1}})
})();
jsTranslateRouteToLines is also an async query that returns an object.
However, data1 is undefined.
jsTranslateRouteToLines doesn't actually need to use the async pattern (I just default to that most of …
Another way (using older JS techniques that some are more comfortable with) is to use promises:
https://docs.retool.com/docs/scripting-retool#promises-and-async-queries
Thanks,
Really helpful, this will keep everything a bit more organized!