I am using fetch to get data and once response received assigning the value to javascript output variable and assigning to a local variable.
fetch taking some time to get response, before this time next assignments are happening and flow is ending.
how to block execution until response received.
here I am getting $resolve is not defined ERROR.
Hi @Kiran Kumar Siluveru can you give context and more info error about this?
Its hard to try to figure out what is happening.
check the documentation https://success.outsystems.com/documentation/11/reference/errors_and_warnings/errors/invalid_reference_error/
here in the fetch success block I am calling $resolve() which is giving undefined error, in below screenshot, I have commented that line for testing purposes Please ignore that.
FYI : parent function is async function only.
hi please check this:
Promises allow you to execute, compose and manage asynchronous operations. They allow for asynchronous methods to return values like synchronous methods do. However, instead of the final value, the asynchronous method returns a promise for the value at some point in the future (or never).
For more information on using promises, check the Mozilla Developer Network documentation on Promises.
Define an Asynchronous Client Action
In an JavaScript element there are two predefined functions available for use: "$resolve()" and "$reject()". These functions are very similar to the usual "resolve()" and "reject()" functions used together with promises, but "$resolve()" doesn't take any arguments; output values should be set through the "$parameters" predefined object.
To signal a successful execution of the asynchronous client action being called, use the "$resolve()" predefined function.
For example, if you have a "GlobalAsyncAction" client action and you want to signal a successful execution to its caller, you can add the following code to a JavaScript element in the "success" path of the action flow:
// Return success in GlobalAsyncAction client action$parameters.Success = true;$parameters.Out1 = 5.0;$resolve();
The predefined function "$resolve()" doesn't take any arguments. To define output values in your client action, set them using the "$parameters" predefined object, as shown above.
https://success.outsystems.com/documentation/11/extensibility_and_integration/javascript/extend_your_mobile_and_reactive_apps_using_javascript/defining_asynchronous_javascript_code/
check this to
https://www.outsystems.com/forums/discussion/43997/resolving-promises-in-mobile-javascript/
regards,
Hi,
There should only one $resolve() in your code. After OutSystems executes it, execution continues after the javascript widget in your action.
The $public.resolve() in your code doesn't make sense to me.
Regards,
Daniel