87,910
社区成员
发帖
与我相关
我的任务
分享
const bluePromise = require('bluebird');
const test = async ctx =>{
await new bluePromise((r)=>{r(8)}).then((r)=>{
console.log("bluebird: "+r);
ctx.body = "bluebird promise";
});
await new Promise(r=>{r(2)})
.then(r=>{
console.log(r);
})
.then(r=>{
ctx.body = "native promise";
});
console.log("end");
};
const test = async ctx =>{
new Promise(r=>{r(2)})
.then(r=>{
console.log(r);
})
.then(r=>{
ctx.body = "native promise";
});
console.log("end");
};
async function midware(){
return new Promise(r=>{setTimeout(()=>{r(10)},1000);})
.then(r=>{console.log("p1");})
.then(r=>{console.log("p2");})
}
async function r(){
await midware();
next();
}
(async ()=>{
var r= await (()=>{return 3})();
console.log(r);
})()