I want a path like so: /skittles?type[]=blue&type[]=green (just like a x-www-form-urlencoded, but this is a get request for an api).
So if I have the following code, how would I add the optional parameters to the route path (currently /skittles)?
app.get('/skittles', callback);
                You don't need to add them to the path.  You'll find them in the req.query object.
var util = require('util');
app.get('/skittles', function(req, res) {
  console.log(req.query);
  var type = req.query.type || [];
  console.log("type: "+util.inspect(type));
  res.send("Type: "+util.inspect(type));
});
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With