title: Using POST without a form in jade and node.js?
body: <p>I am trying to make a delete option for some items I have in a list. The way I am doing this is to give every item in the list a button or a link of some sort that will use POST to send the _id (from mongodb). As you can see in the code below (req.body.id), I'm trying to get the id form the request. However, the request does not have the id, because I don't know how to do this without using a form and a input field.</p>
  
  <p>I've seen some ways to do it with javascript in PHP. But is there a more jade and node.js specific way?</p>
  
  <pre><code>router.post("/deleteitem", function(req,res) {
    var db = req.db;
    var collection = db.get("itemcollection");
    id = req.body.id;
  
    collection.remove({
      "_id": id
    }, function (err, removed) {
      if (err) {
        res.send("Error");
      }
      else {
        res.redirect("editlist");
      }
    });
  });
  </code></pre>
  
  <p>Thanks for the help.</p>
  
  <p>Edit: </p>
  
  <p>Client-side:</p>
  
  <pre><code>extends layout
  
  block content
      h1.
          Items
      ul
          each item, i in editlist
              li
                  p #{item.name} costs #{item.price}
                  button#btnSubmit(type="button",method="post",action="/deleteitem") Delete
  
      a(href="/") Back to start
  </code></pre>
  
  <p>The button part is not very relevant though. Firstly I am not sure if it's possible to do it this way. Secondly I have not included the id in any way. I was just experimenting. </p>
  
  <p>One way I could probably do it is to include the id in the url as a parameter. But that seems a bit more convoluted than just using POST and including the id in the request.</p>