Ashish
Ashish

Reputation: 8529

retrieving multiple query string parameters Express 4

var express = require('express');
var bodyParser = require('body-parser');
var app = express();
var url = require('url');

// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }));

// parse application/json
app.use(bodyParser.json())
app.get('/', function (req, res) {
  console.log(req.query); 
  res.send('Hello World');
})

app.listen(3000);


curl http://localhost:3000/?a=1&b=3

The console log returns { a: '1' }.

Am I missing something ?

Upvotes: 1

Views: 1164

Answers (1)

DanielKhan
DanielKhan

Reputation: 1208

& is a shell command that backgrounds your process so everything after & will not be passed to curl.

You need to use curl 'http://localhost:3000/?a=1&b=3' (note the quotes)

Upvotes: 3

Related Questions