Is there any way to ensure an Injected JS function finishes before a Synchronous API call is made?

Viewed 23

I have a problem with my JS code having a race condition with a synchronous API call. Please keep in mind, I have to inject my code via a tag manager and I have no direct access to the code in the web app. What I did was set an event listener on the "Continue" button of a view so that when the button is clicked, it invokes some marketing pixels in an iframe. The issue is, about 15% of the time, my code never works due to the web app making a synchronous API call and killing my functionality. I'm looking for different options on possible workarounds. I've looked at questions like: Call a function before synchronous call but I'm assuming my problem is much more complicated due to the fact that I have to use a Tag Manager to inject my code and have no access to the web app code directly. Any advice or ideas are greatly appreciated!

0 Answers
Related