Run query periodically with ternary operator to enable/disable

I'm trying to trigger my API to fetch data every 10 seconds if the current time is between 5am and 9am only.

For the sake of testing I've changed the ternary operator code to the testing current time.

The ternary operator works fine, it returns true or false however the query fails to run when I use it. When I load the page on the ternary operator being = to true and it then changes to false because time has passed the query never triggers despite it being set to run periodically every 10 seconds. I've watched the API state with 'isFetching' inserted into a text component on the app in preview mode and it never changes from 'false' as the the ternary operator changes from true to false.

I can't put the ternary operator in a separate JS query because the JS query doesn't provide the ability to run periodically. On testing it seems that using the ternary operator breaks the 'run periodically' setting.

{{ moment().isBetween(moment().hour(12).minute(59).second(0), moment().hour(13).minute(0).second(0)) ? false : true }}

I think it's to do with when the operator is evaluated and the values inside that aren't changing (I know that time is changing but it's not running the moment() function each loop)

You could have an empty query that runs every 10 seconds and uses onSuccess to trigger your API call only if the current time is in that window - but I really wouldn't advise that you call an API query every 10 seconds!