const { mysql } = require('../qcloud')
module.exports = async (ctx, next) => {
mysql('cAppinfo').select('*').then(res => {
ctx.state.code = 0
ctx.state.data = res
}).catch(err => {
ctx.state.code = -1
throw new Error(err)
})
}
这段代码放在app.js文件下可以打印出正确的数据,却在controllers文件夹下进入不到then阶段
项目克隆自:https://github.com/tencentyun...
卡在这里好久了,求指导?
因为查询数据库是异步,所以在mysql前面加await。