title: cannot read properties of undefined(reading"name")
body: <p>I trying to make a survey website and I have been stuck on this bug for hours. I have a from that has 5 inputs and it takes name, question and 4 options as text and submits them. when clicking on submit button the server recieves a post method with the action /all after getting /all the server should render all.ejs. below is my index.js file:</p>
  <pre><code>router.post('/all', function (req, res) {
  
  
  const newsurvey=new survey({
  
  &quot;name&quot;:req.body.name,
  &quot;question&quot;:req.body.question,
  &quot;option1&quot;:req.body.option1,
  &quot;option2&quot;: req.body.option2,
  &quot;option3&quot;:req.body.option3,
  &quot;option4&quot;: req.body.option4,
  
  
  
   }) 
    survey.create(newsurvey)
    console.log(newsurvey)
    console.log(req.body.name)
    res.render('all', { title: 'All Surveys', survey});
  });
  // initializing a new survey object
  router.get('/addsurvey', function (req, res, next) {
    survey.find((err, list)=&gt;{
      const newsurvey = new survey({
      &quot;name&quot;:&quot;&quot;,
      &quot;question&quot;:&quot;&quot;, 
      &quot;option1&quot;:&quot;&quot;,
      &quot;option2&quot;:&quot;&quot;,
      &quot;option3&quot;:&quot;&quot;,
      &quot;option4&quot;:&quot;&quot;
    }
  )}
    
    ,res.render('surdetails', { title: 'Details', survey})
    
    );
    
  });
  router.get('/all', function (req, res) {
    survey.find((err, list)=&gt;{
      if (err){
        return console.error(err);
      }else{
        res.render('all', { title: 'All Surveys', survey: survey });
  
      }
    })
    
  });
  </code></pre>
  <p>and below is my all.ejs file which returns cannot read properties of undefined(reading&quot;name&quot;):</p>
  <pre><code>&lt;tbody&gt;
      &lt;!-- Template Row --&gt;
      &lt;% for (let count = 0; count &lt; survey.length; count++) { %&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;%= survey[count].name %&gt;&lt;/td&gt;
        &lt;td class=&quot;text-center&quot;&gt;&lt;%= survey[count].name %&gt;&lt;/td&gt;
        &lt;td class=&quot;text-center&quot;&gt;&lt;%= survey[count].question %&gt;&lt;/td&gt;
        &lt;td class=&quot;text-center&quot;&gt;
          &lt;input type=&quot;radio&quot; id=&quot;option1&quot; name=&quot;option1&quot; value=&quot;&lt;%= survey[count].option1 %&gt;&quot;&gt;
          &lt;label for=&quot;option1&quot;&gt;&lt;%= survey[count].option1 %&gt;&lt;/label&gt;&lt;br&gt;
          &lt;input type=&quot;radio&quot; id=&quot;option2&quot; name=&quot;option2&quot; value=&quot;&lt;%= survey[count].option2 %&gt;&quot;&gt;
          &lt;label for=&quot;option2&quot;&gt;&lt;%= survey[count].option2 %&gt;&lt;/label&gt;&lt;br&gt;  
          &lt;input type=&quot;radio&quot; id=&quot;option3&quot; name=&quot;option3&quot; value=&quot;&lt;%= survey[count].option3 %&gt;&quot;&gt;
          &lt;label for=&quot;option3&quot;&gt;&lt;%= survey[count].option3 %&gt;&lt;/label&gt;&lt;br&gt;&lt;br&gt;
        &lt;/td&gt;
        &lt;td class=&quot;text-center&quot;&gt;
          
          &lt;a href=&quot;/delete/&lt;%= survey[count]._id %&gt;&quot; class=&quot;btn btn-primary&quot;&gt;&lt;i class=&quot;fa fa-trash-o&quot;&gt;&lt;/i&gt; Delete&lt;/a&gt;
        &lt;/td&gt;
  
       
      &lt;/tr&gt;
      &lt;% } %&gt;
    &lt;/tbody&gt;
  </code></pre>