
module.exports = function (req, res, next) {
  try {
    var rawBody = req.body;
    var parsedBody = JSON.parse(rawBody);
    req.body = parsedBody;
  }
  catch (e) {
    console.trace('Exception while parsing body: ', req.body, e);
    req.body = {};
  }
  next();
};


module.exports = function (req, res, next) {
  try {
    var rawBody = req.body;

    if (typeof rawBody !== 'object') {
      var parsedBody = JSON.parse(rawBody);
      req.body = parsedBody;
    }
  }
  catch (e) {
    console.trace('Exception while parsing body: ', req.body, e);
    req.body = {};
  }
  next();
};

Fix bug in parsing empty request bodies
Fix bug in parsing empty request bodies

Signed-off-by: shaisachs <47bd79f9420edf5d0991d1e2710179d4e040d480@ngpvan.com>
