需求,兩個異步請求,第二個請求參數為第一個請求返回值
將第一個請求封裝為async函數
async function fn1(){
axios.get().then(()=>{
return '123'
})
}
fn1().then((result)=>{
axios.get().then(()=>{
return '456'
})
})
第二種
function getList(){
return new Promise( function( resolve,reject){
axios.get().then(()=>{
resolve(123)
})
})
}
async function fn3(){
let first = await getList();
let second = await getList();
let third = await getList();
console.log(first,second,third)
}