Category: How do I do X?
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

Have to add delays after query.run() before reading query.data in JSObjects

Issue

I am experiencing an issue with using queries within JSObjects. Even after awaiting query.run() I still have to add delays to make sure accessing query.data doesn't fail. I'm wondering if I am missing something.

Resolution

The solution to the issue of having to add delays when accessing Query data after running a query in JSObjects is to use the shorthand syntax: "const res = await query.run()". This will always grab the response from the query and eliminate the need for extra delays. The "Query.data" property can still be used to bind query data to widgets, but in raw JS, the shorthand syntax is recommended for accessing the query response.