How do I wait for a promise to finish before returning the variable of a function? How do I wait for a promise to finish before returning the variable of a function? javascript javascript