I am not getting the error that why that array is not pushing into parameter Here is my code in session.poll_questions_list.push I am trying to push array but getting an error like "Cast to ObjectID failed for value"
router.put('/session/updatepoll/:sessionID', function(req, res) {
Session.findById(req.params.sessionID, function(err, session) {
if (err) {
return res.send(err);
}
if (session) {
if (req.body.poll_enabled) {
session.poll_enabled = req.body.poll_enabled;
session.poll_type = req.body.poll_type;
session.poll_questions_list.push(req.body.poll_questions_list);
session.save(function(err, session) {
if (err) {
return res.send(err);
} else {
res.json(session);
}
})
}
if (!req.body.poll_enabled) {
session.poll_enabled = req.body.poll_enabled;
session.poll_type = "";
session.poll_questions_list = [];
session.save(function(err, session) {
if (err) {
return res.send(err);
} else {
res.json(session);
}
})
}
}
})
})
via Ikshit Mathur
No comments:
Post a Comment