Promises and async/await are both ways to handle asynchronous code in JavaScript.
A promise is an object that represents the eventual completion (or failure) of an asynchronous operation,
and its resulting value. Promises were introduced to handle asynchronous operations in a more elegant way,
compared to the callback-based approach.
Async/await is a more recent addition to JavaScript and it is built on top of promises.
It allows you to write asynchronous code that looks and behaves like synchronous code.
Both of the above codes will do the same thing,
but the second one is written with async/await and looks more similar to synchronous code.
It is more readable and less complex.
Promises are more powerful and flexible than async/await, but async/await is more convenient for simple cases,
and it’s easier to read and write. Async/await is best used in cases where the asynchronous code is simple
and doesn't require chaining multiple promises.
In cases where more complex control flow is needed, Promises should be used.
In a nutshell, if you're working on a new project and you don't have a preference for one over the other,
I would recommend using async/await as it is more readable.
But if you're working on an existing project that uses Promises, you may want to stick with Promises.