I have a Submit button on one of my pages which must do three things:
- Redirect the browser to an external website using wix-location.to(), and
- Invoke wix-fetch.fetch() on a different external website to create a row in a table, .then()
- Invoke wix-fetch.fetch() again to create a reference to #2 via a foreign key relationship.
The to() method returns null (not a Promise) so presumably that means the browser goes over to the new page immediately. The fetch() method returns a Promise. Steps 2 and 3 could take a while to execute and frankly it’s not the user’s concern what happens so I’d prefer to just send them immediately to the new browser URL via step #1 while 2 and 3 run in the background.
My question is this: By redirecting the browser to #1 immediately, will #2 and #3 run to completion even though the browser is off doing different stuff? In Java the thread running #2 and #3 would likely be deleted before it could finish execution. In Javascript in a browser environment, I have no idea. (shrug emoji)
Please advise and thanks!