promise implements two requests, and the third step is to show the result. For the second request, you can get the result of the first request, but when you get to the third step, the res is not the res, returned by the second request.
let a=new Promise((res,rej)=>{
//
setTimeout(()=>{
res("data")
})
})
a.then((res)=>{
//
setTimeout(()=>{
console.log("");
},3000)
}).then((res)=>{
//
console.log(res+"");
})
if this function is changed to write in asyncawait,
function a() {
return new Promise((res, rej) => {
setTimeout(() => {
console.log("1");
res(1)
}, 2000)
})
}
function c() {
return new Promise((res) => {
setTimeout(() => {
console.log("2");
res(2)
}, 3000)
})
}
async function b() {
await a()
await c()
}
let d=b()
c is originally executed in a, but after an executes, it takes the parameters from a to make a request or other operation. Now it is also in a mode similar to Synchronize, how can c get the parameters that were originally sent by a.