Run Javascript twice for query to have acurate data

I have to run a Javascript function 2 times, that contains a database query inside before I get accurate (current) data.

For simplicity: I have a table in the retool Database call test_async.
It has one row
{ pk: 1 (int),
my_number: 50 (int) }
The query getTestAsync

SELECT pk,my_number FROM test_async;

Query caching is off.

The javascript function:

async function helloTest() {
await getTestAsync.trigger();
return getTestAsync.data;
}
return helloTest();

I have to run the function 2 times to get data that has changed.

  1. If my_number=50. I run the helloTest() and 50 is returned.
  2. Change my_number=10. I run the helloTest() and 50 is returned.
  3. Run the helloTest(). 10 is returned.

I have tried the following:
1)await
2)then
3) on success
4) making a timeout loop,
5) triggering the query twice.

async function helloTest() {
await getTestAsync.trigger();
await getTestAsync.trigger();
return getTestAsync.data;
}
return helloTest();

Hi @clay123,

Would it work to reference getTestAsync.data directly? Rather than via your JS query.

If you need to keep the JS query, I believe this should also work: return await getTestAsync.trigger()