How to rewrite a callback function in Promise form and async/await form in JavaScript