middleOne 如何打印到 middleTwo await 之后的结果·· "express": "^4.18.2",

查看 38|回复 0
作者:cutemurphy2888   
const express = require('express');
const app = express();
const vv = {
}
const middleOne = async (req, res, next) => {
await next();
console.log(vv, 'middle1');
}
const haha = () => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve('hahahhahhah');
}, 3000);
})
}
const middleTwo = async (req, res, next) => {
const result = await haha();
vv.uname = result;
console.log(vv, 3232);
next();
}
app.use(middleOne);
app.use(middleTwo);
app.get('/', (req, res, next) => {
res.send({
'cute': 'murphy'
});
})
app.listen(3002, (res) => {
console.log(res, 22);
})
您需要登录后才可以回帖 登录 | 立即注册

返回顶部