title: Matching a delete request to a json object
body: <p>I am trying to delete a json object from the json file when that object values are displayed in a form using the AJAX Delete function. I am using express to generate a route for the json file like below:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>app.get('/users', (req, res) =&gt; {
      var userData = json;
      
      res.send(userData);
          
          }), 
          
  app.delete('/users/delete/:id', (req, res) =&gt; {
      var key = req.params.id;
      var deletedData = json;
      
      deletedData.splice(key, 1);
      res.send(deletedData);
  
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>      $(document).on('click', '#delete', function () {
               $.ajax({
                      type: "DELETE"
                      , url: "users/delete/"+data[key]  
                      , datatype: "datatype"
                      , success: function (data) {
                          console.log(data);
         
                          }   
                  });
              });</code></pre>
  </div>
  </div>
  </p>
  
  <p>I  know I havent declared the data[key], that is just context for what i would like to do. My issue is trying to select the specific json object rather than just selecting the first object with what I have now "users/delete/0', would anyone know how to do this?</p>
  
  <p>EDIT</p>
  
  <p>I am trying to get the "users/delete/:id" specific to the object that is displayed in my form in the html</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>                &lt;div class="col-md-5 col-sm-12"&gt;
                      &lt;div id="full_details"&gt;
                          &lt;ul class="details"&gt;
                              &lt;h2&gt;Contact Details&lt;/h2&gt; &lt;img src="" alt="Avatar" id="avatar"&gt;
                              
                              
                              &lt;li&gt;Name
                                  &lt;input type="text" id="name" class="form-control mr-sm-2" disabled&gt;
                              &lt;/li&gt;
                              &lt;li&gt;Address
                                  &lt;input type="text" id="address" class="form-control mr-sm-2" disabled&gt;
                              &lt;/li&gt;
                              &lt;li&gt;Contact Number
                                  &lt;input type="text" id="phone" class="form-control mr-sm-2" disabled&gt;
                              &lt;/li&gt;
                              &lt;li&gt;Email
                                  &lt;input type="text" id="email" class="form-control mr-sm-2" disabled&gt;
                              &lt;/li&gt;
                              &lt;li&gt;Postcode
                                  &lt;input type="text" id="postcode" class="form-control mr-sm-2" disabled&gt;
                              &lt;/li&gt;
                              &lt;li&gt;City
                                  &lt;input type="text" id="city" class="form-control mr-sm-2"disabled&gt;
                              &lt;/li&gt;
                              &lt;li&gt;Country
                                  &lt;input type="text" id="country" class="form-control mr-sm-2" disabled&gt;
                              &lt;/li&gt;
                              &lt;div class="row"&gt;
                                  &lt;div class="col-md-6"&gt;
                                      &lt;div id="editbutton"&gt;
                                          &lt;p class="btn btn-primary"&gt;Edit Details&lt;/p&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                                  &lt;div class="col-md-6"&gt;
                                      &lt;div id="savebutton"&gt;
                                          &lt;p class="btn btn-danger"&gt;Save Details&lt;/p&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                                  &lt;div class="col-md-6"&gt;
                                      &lt;div id="delete"&gt;
                                          &lt;p class="btn btn-danger"&gt;delete&lt;/p&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/ul&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>