02. Async Function Syntax
Async functions defined as a regular functions:
Async function has the keyword
async
before it.The
await
keyword can only be used inside functions defined withasync
.
Вызов асинхронной функции выглядит так же как и вызов любой другой функции.
Return value
Any async function returns a promise implicitly, and the resolve value of the promise will be whatever you return from the function.
Обычный
return
возвращает Promise установленный в возвращаемое значение.Выброс ошибки возвращает Promise установленный в ошибку.
Нормальный случай:
Выброс исключения:
Last updated
Was this helpful?