Chaining Queries - Best Practice?

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.

You can get more advanced my return values from one javascript query to another:

Another way (using older JS techniques that some are more comfortable with) is to use promises:


Really helpful, this will keep everything a bit more organized!