userIdwhich is a variable that I defined in the first line of the function, when I place the return block outside the coroutine scope, it returns an empty string, how do I return it inside the scope so it can run when the coroutine is finished, or any other way to return after the coroutine is finished
Answer:In order to make a function returns a pending value; it should be a
suspendfunction to return the value asynchronously.
Then, instead of the
async/awaitbuilder can be used to return a
await()waits until it’s assigned a value by the Coroutine
Applying that in code:
If you have better answer, please add a comment about this, thank you!