I guess it is a timing issue. The order of which the console.logs trigger seems to indicate that. I’ll give the async await a try.
If I keep having problems then I’ll probably do something with a while loop and perhaps storing the value temporarily in a hidden text box or something like that. That would be ugly, but should at least work.