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.
- If my_number=50. I run the helloTest() and 50 is returned.
- Change my_number=10. I run the helloTest() and 50 is returned.
- 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();