async function getLessonQuestion(req,res){
let lessonId = req.body.lessonId;
let companyId = req.body.companyId||"";
try{
let query = new AV.Query(models.Question);
query.equalTo('belongToLesson', AV.Object.createWithoutData('Lesson', lessonId));
if(companyId!==""){
query.equalTo('belongToCompany',AV.Object.createWithoutData('Company'),companyId);
}
query.include('belongToLesson');
query.include('user');
query.include('user.avatar');
query.include('user.belongToCompany');
query.limit(10);
let questions = await query.find();
res.send({
code:0,
data:questions
})
}catch (error){
res.send(error)
}
}
两个方法类似,然后app.post('/api/company/notifyNoJoin', companyApi.notifyCompanyNoJoinMember);这种方式调用
斯凯 14:46:14
只要前端执行两次,就未登录了
就是req里的
req.AV.user就不存在了
斯凯 14:46:42
如果换成promise就没问题,用这种async和await就会有这样的问题,因为最近想使用await来解决回调就出现了现在的问题,之前都是写Promise