var express = require('express'); var app = express(); app.get('/', function(req, res){ res.send('id: ' + req.query.id); }); app.listen(3000);

get query parameters in node.js

// GET /search?q=tobi+ferret console.dir(req.query.q) // => 'tobi ferret' // GET /shoes?order=desc&shoe[color]=blue&shoe[type]=converse console.dir(req.query.order) // => 'desc' console.dir(req.query.shoe.color) // => 'blue' console.dir(req.query.shoe.type) // => 'converse' // GET /shoes?color[]=blue&color[]=black&color[]=red console.dir(req.query.color) // => ['blue', 'black', 'red']

expressjs query params

Similar Code Examples