我在我的koa应用程序中使用koa-session来存储一些数据。下面是我的代码:
/*some code*/
app.use(session(app));
/*some code*/
router.get('/test', async (ctx) => {
const {session} = ctx;
console.log(session['test']) // always undefined
session['test'] = 'test'
});我希望在第一个请求上获得undefined,在其他请求上获得'test',但我总是得不到定义。这段代码有什么问题?
发布于 2019-02-01 06:52:22
试一试
ctx.session.test = "testsessiondata"https://stackoverflow.com/questions/54456635
复制相似问题