Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Query.data Returns Undefined After Awaiting Query Run in an JS Function That Runs on Page Load #33335

Open
1 task done
ame-appsmith opened this issue May 9, 2024 · 0 comments
Assignees
Labels
Bug Something isn't working FE Coders Pod Issues related to users writing javascript in appsmith JS Evaluation Issues related to JS evaluation on the platform Medium Issues that frustrate users due to poor UX Needs Triaging Needs attention from maintainers to triage Production

Comments

@ame-appsmith
Copy link

ame-appsmith commented May 9, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Description

The user runs a query, then stores the data returned to Appsmith store. The code snippet used is similar to the below one:

await Query1.run();
await storeValue('myData', Query1.data[0], false);

However, the code does not run as expected and the value stored to Appsmith store is undefined, although the await keyword was used; hence, the query should have run before the result was stored to Appsmith store.
This behavior is only present if the code is run on page load. If it is run manually, it always returns the expected result.

The workaround is to assign the query run to a variable and store this variable to Appsmith store by using the following snippet instead, which is safer:

let myQueryData = await Query1.run();
await storeValue('myData', myQueryData[0], false);

However, the first approach should have worked too, since the await keyword was used correctly.

Steps To Reproduce

Ticket with screenshots of the original code

Public Sample App

No response

Environment

Production

Severity

Medium (Frustrating UX)

Issue video log

No response

Version

Self Hosted

@ame-appsmith ame-appsmith added Bug Something isn't working Needs Triaging Needs attention from maintainers to triage JS Usability usability issues with JS editor and JS elsewhere labels May 9, 2024
@Nikhil-Nandagopal Nikhil-Nandagopal added Medium Issues that frustrate users due to poor UX Production labels May 9, 2024
@github-actions github-actions bot added the FE Coders Pod Issues related to users writing javascript in appsmith label May 9, 2024
@ame-appsmith ame-appsmith changed the title [Bug]: Query.data Returns Undefined After Awaiting Query Run [Bug]: Query.data Returns Undefined After Awaiting Query Run in an JS Function Run on Page Load May 10, 2024
@ame-appsmith ame-appsmith changed the title [Bug]: Query.data Returns Undefined After Awaiting Query Run in an JS Function Run on Page Load [Bug]: Query.data Returns Undefined After Awaiting Query Run in an JS Function That Runs on Page Load May 10, 2024
@Nikhil-Nandagopal Nikhil-Nandagopal added JS Evaluation Issues related to JS evaluation on the platform and removed JS Usability usability issues with JS editor and JS elsewhere labels May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working FE Coders Pod Issues related to users writing javascript in appsmith JS Evaluation Issues related to JS evaluation on the platform Medium Issues that frustrate users due to poor UX Needs Triaging Needs attention from maintainers to triage Production
Projects
None yet
Development

No branches or pull requests

4 participants