javascript await promise in synchronous function