Async functions are built on top of Promises. They can contain an await expression that pauses the execution of the async function and waits for the passed Promise’s resolution before resuming the async function’s execution and returning the resolved value. The purpose of async/await functions is to simplify the behavior of using promises synchronously and to perform some behavior on a group of Promises.

See the Pen thecodelog.com - ES8 Async Functions 1 by Deano (@deangilewicz) on CodePen.

await is only valid in an async function otherwise you will get a SyntaxError.

See the Pen thecodelog.com - ES8 Async Functions 2 by Deano (@deangilewicz) on CodePen.

To handle async function errors you can use try/catch.

See the Pen thecodelog.com - ES8 Async Functions 3 by Deano (@deangilewicz) on CodePen.

Another solution to handle errors is to create a higher order function that you can use to wrap async functions.

See the Pen thecodelog.com - ES8 Async Functions 4 by Deano (@deangilewicz) on CodePen.