How to create and use promises with async await in javaScript

preview_player
Показать описание
we create a new Promise using new Promise().
A Promise takes a function as an argument, called the executor function.
This function has two parameters:
resolve → Call this when the operation succeeds.
reject → Call this when the operation fails.

You put async before function to tell javaScript that is a asynchronous operation inside.
You put await • await tells JavaScript:
🛑 "Pause here until the code will finish with succes or with failure
If will rejects (fails), JavaScript jumps straight to the catch block.
Рекомендации по теме
join shbcf.ru