title: How can I parse parameters to a RESTful API
body: <p>I am trying to make a basic RESTful API which works for the most part, but I would like to parse it url parameters such that I can apply multiple filters in one call</p>
  
  <p>I have the following code:</p>
  
  <pre><code>app.get('/api/products/:id',(req, res) =&gt; {
    let sql = "SELECT * FROM products WHERE id="+req.params.id;
    let query = conn.query(sql, (err, results) =&gt; {
      if(err) throw err;
      res.send(JSON.stringify({"status": 200, "error": null, "response": results}));
    });
  });
  </code></pre>
  
  <p>which I can use to apply one filter when I send a request like this:</p>
  
  <p><code>localhost/api/products/1</code></p>
  
  <p>but I would like to get all products with a name and their categories:</p>
  
  <p>IE I would like to send a request like this:
  <code>localhost/api/products?name=stier&amp;category=hammer</code>
  I would also like it to accept requests like this 
  <code>localhost/api/products?category=hammer</code><br></p>
  
  <p>Is that possible and how can I adapt my code to do that.</p>
  
  <p>Thank you in advance </p>