Javascript Run Async Function Synchronously