Key points of async await

1. Await can be appended with a promise object

Await can get the value inside the Promise object

eg:

await ( promise.resolve({abc:132= {}))abc:132}
Copy the code

Await can also wait for asynchronous completion after executing code

2. Await should be wrapped inside async function

let test = async() = > {await-}Copy the code

3. Async also returns a Promise object

let test = async() = > {return 1;
}
test == promise.resolve(1)
Copy the code

4. Try-catch Intercepts reject in promise

 let test = async() = > {try{
         await-}catch(err){
         console.log(err)
     }
    
}
Copy the code