javascript convert async function to promise