PROBLEM #1 (SOLVED) - MAKING PROMISES WORK IN BROWSER -> EXECUTE JAVASCRIPT
I'm now struggling with integrating with the existing API built for my client. The API relies almost entirely on javascript promises. I have found that promises don't work directly in Browser -> Execute Javascript() because promises don't work with eval(), and that is the basis for the Construct event.
I found that I have been able to work around this by wrapping the promise in an anonymous function, casting the MOPusername promise as a new MOPusername object:
Browser -> Execute Javascript "MOPusername = Service.GetUser().then(GetUserResponse => { document.getElementById(""getUserResponse"").value = GetUserResponse.Username;
//GetUserResponse.IsGuest
//GetUserResponse.Username
return GetUserResponse;
//if(ErrorOccurred (GetUserResponse)) {
// abort
//}
}).then(result => {return result.Username});"
Browser -> Execute Javascript "(async () => {MOPusername = await MOPusername})()"
PROBLEM #2 - MAKING .then() CALL c2_callFunction() IN BROWSER -> EXECUTE JAVASCRIPT
The next problem is proving to be beyond me. For some reason I can't get c2_callFunction() to work within a promise when called from BROWSER -> EXECUTE JAVASCRIPT.
The following works when typed into the console. The expected result is .Success = 1:
When run from inside Construct 3, however, it gives a different result of .Success = 0:
Ashley, is there anything going on that would wait for the promise to be resolved in the console before c3_function("setUserResult") is called, but NOT wait for the promise when c3_function("setUserResult") is called inside a Browser -> Execute Javascript within Construct 3?