怎么通过请求上下文异步传递信息

查看 41|回复 1
作者:ddddad   
目前使用了 express-http-context2 ,
但是感觉有 bug ,在后续中无法获取设置的值
const app = express();
app.use(middleware); // use http context
if (!excludeAuth(req)) {
        await verifyJWT(req, resp);
console.log(get(HTTP_CONTEXT.ORG_ID));
}

req, 上下文, await, const

leopod1995   
https://www.npmjs.com/package/express-http-context
感觉可能是写法问题? 检查版本
1. Install: npm install --save express-http-context
(Note: For node v4-7, use the legacy version: npm install --save express-http-context@<1.0.0)
2. Make sure you require express-http-context in the first row of your app. Some popular packages use async which breaks CLS.
3. Node 10.0.x - 10.3.x are not supported. V8 version 6.6 introduced a bug that breaks async_hooks during async/await. Node 10.4.x uses V8 v6.7 in which the bug is fixed. See: https://github.com/nodejs/node/issues/20274.
您需要登录后才可以回帖 登录 | 立即注册

返回顶部