async await

总是记不住async和await。一个栗子就想起来了。

function getFinal(){
      getCode().then(function(res){
         if(res.data.code == 0){
                 var params = {
                      code:res.data.code
                  }
               getlist(params).then(function(res){
                    if(res.data.code == 0){
                       }
                   })
                }
          })
      }
  getFinal();
async function getResult(){
            let code = await getCode();
            if(code.data.code == 0){
                var params = {
                    code:code.data.code
                }
                let list = await getlist(params);
            }
        }
getResult();

 

posted @ 2020-06-28 14:16  superil  阅读(96)  评论(0编辑  收藏  举报