lowcoder icon indicating copy to clipboard operation
lowcoder copied to clipboard

[Feat]: Support 'await' operator in JS scripts.

Open rjamesnw opened this issue 9 months ago • 0 comments
trafficstars

Is your feature request related to a problem? Please describe. I have a script that I made that allows me to use await but I keep having to wrap it:

return (async ()=>{ var result = await ... });

Then I have to do this, which seems silly: Image

But if .run() already returns a promise, when why am I not able to use 'await' in the script body? Seems the code is node being run in an async function even though a promise is being used.

Describe the solution you'd like Be consistent, if .run() returns a promise, allow await operators in the script body by using async functions.

Describe alternatives you've considered One ay is to run sync code to run async, so

doIt();
return;
async function doIt() { ... await ... }

Which is just silly, since .run() runs it async anyhow. Also, that way is no good if you want to return a value.

The best alternative way that works so far:

return (async ()=>{
 .... await stuff ...
})();

Seems if I return a promise at least the system detects it and that works for now.

rjamesnw avatar Feb 05 '25 01:02 rjamesnw