0
以下は、私のコードです:未処理の拒絶はTypeError:プロパティを読み取ることができませんヌルの「名前」
router.post('/getTrainingProgramByTPType', function (req, res) {
var query = { ... }; // simplified for clarity in stackoverflow
models.TrainingProgram.findAll(query).then(function (trainingPrograms) {
var resData = [];
console.log(typeof req.body.userType, req.body.userType);
trainingPrograms.forEach(trainingProgram => {
if (trainingProgram.CourseType.name === req.body.userType || trainingProgram.CourseType.name === "EVERYONE" || (!req.body.isExperienced && trainingProgram.CourseType.name === "OPTIONAL")) {
resData.push(trainingProgram);
}
else {
var resDataCourse = [];
var a;
trainingProgram.Courses.forEach(course => {
course.Classes.forEach(classes => {
classes.ClassRecords.forEach(classRecord => {
if (classRecord.User.email === req.body.email) {
a = 1;
resDataCourse.push(course);
}
});
});
});
if (a === 1) {
resData.push({
id: trainingProgram.id,
name: trainingProgram.name,
description: trainingProgram.description,
imgLink: trainingProgram.imgLink,
courseTypeId: trainingProgram.courseTypeId,
CourseType: trainingProgram.CourseType,
Courses: resDataCourse
});
}
}
});
var datasend = {
success: true,
msg: 'send list success',
trainingProgram: resData,
};
res.send(datasend);
});
});
そして、私はこのエラーを取得しています:
at Promise._settlePromiseFromHandler (C:\Users\huy.q.lam\Desktop\master\DEK-Talentnet\DCC\node_modules\sequelize\node_modules\bluebird\js\release\promise.js:522:17) at Promise._settlePromise (C:\Users\huy.q.lam\Desktop\master\DEK-Talentnet\DCC\node_modules\sequelize\node_modules\bluebird\js\release\promise.js:567:18) at Promise._settlePromise0 (C:\Users\huy.q.lam\Desktop\master\DEK-Talentnet\DCC\node_modules\sequelize\node_modules\bluebird\js\release\promise.js:612:10) at Promise._settlePromises (C:\Users\huy.q.lam\Desktop\master\DEK-Talentnet\DCC\node_modules\sequelize\node_modules\bluebird\js\release\promise.js:691:18) at Promise._fulfill (C:\Users\huy.q.lam\Desktop\master\DEK-Talentnet\DCC\node_modules\sequelize\node_modules\bluebird\js\release\promise.js:636:18) at MappingPromiseArray.PromiseArray._resolve (C:\Users\huy.q.lam\Desktop\master\DEK-Talentnet\DCC\node_modules\sequelize\node_modules\bluebird\js\release\promise_array.js:125:1 9) at MappingPromiseArray._promiseFulfilled (C:\Users\huy.q.lam\Desktop\master\DEK-Talentnet\DCC\node_modules\sequelize\node_modules\bluebird\js\release\map.js:101:18) at Promise._settlePromise (C:\Users\huy.q.lam\Desktop\master\DEK-Talentnet\DCC\node_modules\sequelize\node_modules\bluebird\js\release\promise.js:572:26) at Promise._settlePromise0 (C:\Users\huy.q.lam\Desktop\master\DEK-Talentnet\DCC\node_modules\sequelize\node_modules\bluebird\js\release\promise.js:612:10) at Promise._settlePromises (C:\Users\huy.q.lam\Desktop\master\DEK-Talentnet\DCC\node_modules\sequelize\node_modules\bluebird\js\release\promise.js:691:18) at Promise._fulfill (C:\Users\huy.q.lam\Desktop\master\DEK-Talentnet\DCC\node_modules\sequelize\node_modules\bluebird\js\release\promise.js:636:18) at Promise._resolveCallback (C:\Users\huy.q.lam\Desktop\master\DEK-Talentnet\DCC\node_modules\sequelize\node_modules\bluebird\js\release\promise.js:431:57)
TypeError例外を引き起こしている可能性がありますか?