Thursday, 11 May 2017

raw-body doesn't execute callback

I have a problem with raw-body module for node.js - https://www.npmjs.com/package/raw-body

I try to post some data via AngularJS $http to backend:

$http({
  url: '/api/price/add/',
  method: "POST",
  data: $.param({'productName': $scope.productName, 'price': $scope.price),
  headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).then(....

On backend i process the request via ExpressJS:

app.post('/api/price/add/', function (req, res) {
    var rawbody = require('raw-body');
    rawbody(req, {
    }, function(err, body) {
        console.log("WORK");
    }); }

I expect to see the "WORK" in my log, but i see nothing. Function doesn't execute.

Please help me to understand my mistake.



via Gorcer

No comments:

Post a Comment