So I remember when discussed earlier about async functions? They're basically functions that use the keywords async and await. Wait forces JS to, well, wait on a result before moving to the next line of code. OK, so one of the key things I forgot to emphasize was the concept of Promises and how they are linked to asynchronous functions. You see all async functions return a promise. This promise has two stages in its life cycle and two outcomes. It begins as pending, since the task is being process. If it is successful, it becomes fulfilled and the data is passed or used. If not, then it's rejected, and it will be delivered with an error message.
Async functions can also be missed when using Console commands. It is
possible for a variable to throw an error and for the Console.log show
that same variable initialized with a result. Promises can be showed as
fulfilled, but at the time of run it was pending.
It is important to emphasize that while the function is async, the outer scope is not and will not wait on the promised to be fulfilled. This means you will still have to use .then to provide a callback for the function's end.