A better way to do this (I'm assuming you've initialized your params
variable somewhere else):
request = require('request');
var options = {
url: "http://localhost:9001/v1/sanger/auth/facebook/callback",
method: 'POST',
body: params,
json: true
};
request(options, function (error, response, body) {
... callbacks ...
});
You're not able to get the body
because when you call JSON.stringify(params)
, you're converting params
to a string and you don't have a json
object anymore. If you send the information as plain/text
but tell the request
that you want json
, your express app cannot verify the content-type
, as could check with:
request.get('Content-Type'); // returns undefined
Since you want a json
object, you shouldn't do this. Just pass the json
object, like in the example above.
Then, in your route code, you can do both req.body
or req.param('a_param')
(for a especific key of your json
) to get those values.