wix-location.to() followed by wix-fetch.fetch() - what happens?

I have a Submit button on one of my pages which must do three things:

  1. Redirect the browser to an external website using wix-location.to(), and
  2. Invoke wix-fetch.fetch() on a different external website to create a row in a table, .then()
  3. 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!

Once you’ve done redirection, nothing after it executes - you’re now on a new page with the new page’s code.

Ugh, OK thanks. I’ll do #2 and 3 first, then #1. Maybe present a happy we’re doing stuff message. I suppose if it’s taking too long then I can webhook to Zapier and have it do 2 and 3.