1
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 ?

1
  • The code looks fine to me. I would expect that req.query.b would have the value 3 inside of your route handler. Commented Sep 7, 2015 at 22:13

1 Answer 1

3

& 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)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.