Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

192
Views
I have created an API in node js in request I am getting object but while retrieving it server side showing error

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);
          }
        })
      }
    }
  })
})
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!