노드 js 응용 프로그램과 "오류가 발생한 후에 헤더를 설정할 수 없습니다"라는 경로 중 하나가 있습니다.보낸 후 헤더를 설정할 수 없습니다 - NodeJS
는 경로가 무엇을 : 내 응용 프로그램에서
사용자는 특정 액세스 수준을 때문에,이 경로는 사용자 accessLevel
배열을 통해 이동하고이 경로에 대한 적절한 액세스 수준을 찾습니다. 경로를 호출하는 사용자의 액세스 수준에 따라 다른 작업을 수행합니다.
강령 : 어떤 도움이 크게 감사합니다
app.post('/bios/approve', isLoggedIn, function(req, res) {
for (var i = 0; i < req.user.accessLevel.length; i++) {
if (req.user.accessLevel[i] === "Bio Officer") {
Bio.findOneAndUpdate({userID: req.body.userID, bioForSector: req.body.bioForSector}, {
background: req.body.background,
experience: req.body.experience,
skills: req.body.skills,
bioStatus: req.body.bioStatus
}, function(err, editedBio) {
if (err)
console.log("Error while editing Pending Bio is " + err);
else if (editedBio) {
User.findOneAndUpdate({accessLevel: "Bio Designer"}, {
$push: {biosPending: editedBio._id}
}, function(err, user) {
if (err) {
console.log("The error while finding lineManager is " + err);
} else if (user) {User.findOneAndUpdate({accessLevel: "Bio Officer"}, {
$pull: {
biosPending: editedBio._id
}
}, function(err, bioOfficer) {
if (err) {
console.log("The error while finding lineManager is " + err);
}
res.json("Bio Done!")
});
}
});
}
});
} else if (req.user.accessLevel[i] === "Bio Designer") {
// Currently Empty
} else {
Bio.findOneAndUpdate({userID: req.body.userID,bioForSector: req.body.bioForSector}, {
background: req.body.background,
experience: req.body.experience,
skills: req.body.skills,
bioStatus: req.body.bioStatus
}, function(err, editedBio) {
if (err)
console.log("Error while editing Pending Bio is " + err);
else if (editedBio) {
User.findOneAndUpdate({accessLevel: "Bio Officer"}, {$push: {biosPending: editedBio._id}
}, function(err, user) {
if (err) {
console.log("The error while finding lineManager is " + err);
} else if (user) {
User.findOneAndUpdate({email: editedBio.lineManagerEmail}, {$pull: {biosPending: editedBio._id}
}, function(err, bioOfficer) {
if (err) {
console.log("The error while finding lineManager is " + err);
}
res.json("bio Done!")
});
}
});
}
});
}
}
});
. 아무도 내가 뭘 잘못하고 있는지 알아?
할 수 있습니다 먼저 CB 지옥 밖으로 명확? 그것은 거의 읽을 수 없습니다 ... – CreasolDev
isLoggedIn 함수를 교차 검사하십시오. 거기에 res를 보내지 않습니까? – Nivesh