Promise and async and await usage

  Promise loading is an asynchronous manner using Promise returns a new new processing object, the object may then call a method, then the method has two parameters, the first parameter is executed when loaded successfully, the second parameter is the load fails execution, then the method can be invoked by returning the chain Promise.

 

  async keyword written on the front of the function that returns a Promise, use return in async function, equivalent to the implementation of the Promise of resolve, the return value then called.
  await the meaning is async wait, waiting to be processed, it can only be used in async function, wait for the current to go to the next process is complete.

Guess you like

Origin www.cnblogs.com/wuqilang/p/11204636.html