title: EJS MongoDb Pull items in array
body: <p>Small summary:</p>
  <p>I have a project in Node / Express / MongoDB / EJS.</p>
  <p>I'm setting up the code to edit the arrays, my backend code is working fine (test with PostMan)
  However, I can't get my frontend to work.</p>
  <p>When I click on a.deleteskill there is no reaction neither in the console nor otherwise.</p>
  <p>models :</p>
  <pre><code>skills: {
    type: [
      {
        skill: String,
        level: String,
      },
    ],
  },
  </code></pre>
  <p>routes:</p>
  <pre><code>router.put('/deleteskills/:id/:skill', userController.deleteskill);
  </code></pre>
  <p>controller :</p>
  <pre><code>module.exports.deleteskill = async (req, res) =&gt; {
    const {skill} = req.body;
    try {
      
      await Model.findOneAndUpdate(
        { _id: req.params.id },
        {
          $pull : { 
            skills: {
              skill: langue,
              }
          }
        },
       
        (err, docs) =&gt; {
          if (!err) return res.send(docs);
          if (err) return res.status(500).send({ message: err });
        }
      );
    }   
  catch (err) {
    return res.status(500).json({ message: err });
    
    }
  };
  </code></pre>
  <p>ejs:</p>
  <pre><code>&lt;table class=&quot;tablebox tableskill&quot;&gt;
     &lt;thead&gt;
     &lt;th&gt;Langues&lt;/th&gt;
     &lt;th&gt;Niveau&lt;/th&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
     &lt;div  style=&quot;display: none;&quot;&gt;&lt;p id=&quot;id_user_skill&quot;&gt;&lt;%= user._id%&gt;&lt;/p&gt;&lt;/div&gt;
  &lt;% for(let j = 0; j &lt; user.skills.length; j++) { %&gt;
     &lt;tr&gt;
     &lt;td&gt;
       &lt;input class=&quot;skilllist&quot; type=&quot;text&quot; name=&quot;skill&quot; value=&quot;&lt;%= user.skills[j].skill %&gt;&quot; &gt;
     &lt;/td&gt;
     &lt;td&gt;
        &lt;input type=&quot;text&quot; name=&quot;level&quot; value=&quot;&lt;%= user.skills[j].level %&gt;&quot;&gt;
     &lt;/td&gt;
     &lt;td&gt;
        &lt;a class=&quot;deleteskill&quot; data-user-id=&quot;&lt;%= user._id%&gt;&quot; data-id=&quot;&lt;%= user.skills[j].skill %&gt;&quot; &gt;
           &lt;span class=&quot;material-icons icon-table delete-btn&quot;&gt;
              clear
           &lt;/span&gt;
        &lt;/a&gt;
     &lt;/td&gt;
     &lt;/tr&gt;
  &lt;% } %&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  <p>JS file (refered in the ejs):</p>
  <pre><code>userid = document.getElementById('id_user_skill');
  
  if (window.location.pathname == &quot;/user/edit-user&quot; || window.location.search == `?id=${userid}` ) {
  
    $ondelete = $(&quot;.tableskill tbody td a.deleteskill&quot;);
  
    $ondelete.click(function () {
  
      let id = $(this).attr(&quot;data-id&quot;);
      let iduser = $(this).attr(&quot;data-user-id&quot;);
      let skilldata = `skill: ${id}`
  
      let deleteskill = {
        url: `/api/user/deleteskills/${iduser}/${id}`,
        method: &quot;PUT&quot;,
        data: skilldata
      };
  
      $.ajax(deleteskill).done(function (response) {
        location.reload();
      });
  
    });
  
  } 
  </code></pre>
  <p>Feel free to ask more informations</p>