Understand js's async/await

What are async and await doing?

  async is used to declare that a function is asynchronous

  await is used to wait for the execution of an asynchronous method to complete (in fact, what I understand is that what I am waiting for is an expression, which is a result),

 where await can only appear in async functions 

     The return value of async is a promise object

 

   Compared with promises, async and await handle asynchronous calls more clearly (if there is only one layer, it is not so obvious, if there are multiple layers, it is obvious, there are too many parameters to be passed in promises)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324630138&siteId=291194637