How to return information from remote API back to the Marketo form
I'm trying to display the information sent by API call back to the web page that hosts the Marketo form.
Conceptual flow is as follows:
Web page (Marketo Form) --> Form Submit --> call api (pass form fields as input) --> api executes & returns information as output --> map api output fields to variables --> set (hidden) Form field to variable --> display form fields to users on web page.
This works all the way until the last step where display of form field yields no information that was returned by the API call.
My understanding is that API call is Synchronous, so it will wait for the API to execute and return values.
I have script written in onSuccess() method to read the form variables and display on web page. (this doesn't work!).
I have added wait() function as well to wait for 15 seconds (for testing) hoping it provides enough time for API to execute (which it does within 1/1.5 seconds). Dev Tools Network log shows API returned the values and variables were updated as expected. But these were not available in the onSuccess() method or I am doing something incorrect.
Any help will be appreciated.