如下,我自己单独尝试连接mysql和腾讯暴露的接口连接都不行,求大神帮忙指导下。
另外,我将后端代码上传到腾讯云上面了,如何查看后端代码console.log的打印数据?
module.exports = async (ctx, next) => {
if (ctx.state.$wxInfo.loginState === 1) {
/*const { mysql: config } = require('../config');
var knex = require('knex')({
client: 'mysql',
connection: {
host: config.host,
port: config.port,
user: config.user,
password: config.pass,
database: config.db,
charset: config.char,
multipleStatements: true
}
});
knex('question_sort').select('id').then(res => {
console.log(res)
ctx.state.data = res;
})*/
const { mysql } = require('../qcloud')
mysql('question_sort').select('id').then(res => {
ctx.state.data = res;
})
} else {
ctx.state.code = -1
}
}
回答
mysql查询也是异步,前面加await就好了
楼主,你的问题解决了吗?能交流一下你最后是怎么做的吗?