I am trying to pass some parameters to
my localhost (which is using nodejs) with a CURL command, but my localhost isn't reading
them correctly.
I am doing my POST request to my
localhost like this:
curl --data
"db_name=auto&old_db=Lab.tar.gz&new_db=627999E00_10.tgz"
--noproxy
localhost
-H "Accept: text/plain"
-H "Content-Type: text/plain"
-X POST
http://localhost:8084/auto
And
I try to retrieve my data params with node like
this:
app.post('/auto',function(req,res){
var db_name=req.body.db_name; //undefined
var old_db=req.body.old_db;
//undefined
var new_db=req.body.new_db; //undefined
...
});
But
db_name,old_db,new_db
are all always undefined.
Also, req.body is an
empty object {}
And
req.url is just
/auto
How to I retrieve
the parameters that I passed with my curl program in
node?
==================
Versions
- NodeJS
v6.5.0 - ExpressJS
v3.14.0 - CURL
v7.22.0
==================
Updates
My
ExpressJs configuration is the
following:
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.urlencoded());
app.use(app.router);
app.use(express.static(_path.join(__dirname,
'..',
'Client')));
Also I
tried some other curl
variations:
curl --noproxy
localhost
-H "Accept: text/plain"
-H "Content-Type:
application/json"
-X POST
-d
"{'db_name':'auto','old_db':'Lab.tar.gz','new_db':'627999E00_10.tgz'}"
http://localhost:8084/auto
No comments:
Post a Comment