On my local webserver the following code works perfectly, if i send post request with postman.
var postData;
var form = new formidable.IncomingForm();
form.parse(req,function(err,fields,files){
postData = fields;
});
var userName = postData.userName;
var password = postData.password;
On Heroku i get the following error:
TypeError: Cannot read property 'userName' of undefined
Local is variable postData a form object. On Heroku it us undefined.
This is because of async nature of node.js. Try something like this -