Trigger a query till it gives a specific output

Hi!

I'm having trouble with my app: I have a RESTquery that retrieves a run step (check_run). When i trigger it the first time the response may be "undefined" or "in_progress" and then after a bit (the time depends on how complex the request is) if I trigger it again the status turns in "completed". When it is "completed" I would like to trigger the next query (output).

I would like to know if there is a easy way to do this through all RESTquery settings (General-response-avdance) or what should I do.

Thank you in advance,

Matilde

Hello, you can use "Success" field and "Only run when"
image

you could use

{{ self.data.status === "completed" }}

Just thought I'd point out that depending on the api you're calling you might want to click Debounce and change it to Throttle so you can limit how often the call is made to keep you from hitting a rate limit (or the dreaded blacklist).

There is another way to do this btw, in case future readers want another option. On Success of the query, set the value of a variable we'll call queryResult to the query output. Then go to the Advanced tab for the query and put a checkmark next to "Run this query periodically" and finally in the 'Disable Query' field use a simple(or not) comparison to check the value of the variable for whatever you're looking for:

{{ queryResult.value.status === "completed" }}

for as long as that statement above is not true, then when you trigger the query it'll continue to run every 1000ms. It's basically the same as a Do While loop with pause(1000) after each iteration..

1 Like