angularjs - req.body empty Node.js -
this angular controller code im passing certificationid , userid delete certification details of user.
$scope.deletecertification = function(certificationid){ var username = $scope.userid; var certificationid = certificationid; var deletecertificationinfo = {'username': username, 'certificationid':certificationid}; console.log('deletecertificationinfo*******'); console.log(deletecertificationinfo); userprofileservice.deleteusercertificationinfo(deletecertificationinfo).then (function(data){ console.log($scope.certification); console.log('certification deleted'); }) } userprofiledata.deleteusercertificationinfo = function (deletecertificationinfo) { var deferred = $q.defer(); $http.delete('/api/profileupdate/deleteusercertification', deletecertificationinfo, { }).success(function(res){ var deletedusercertificationresult = res; deferred.resolve(deletedusercertificationresult); $log.debug('response certification api:['+json.stringify(deletedusercertificationresult)+']'); }).error(function(err){ deferred.reject(err); }); return deferred.promise; };
that written in userprofileservice call delete api.
but in node controller function req.body empty. not sure going. im consoling data in front end before sending service . it's displayed then. why req.body getting empty?
try follwing code, worked me , shoud have code in node service js file
app.use(bodyparser.json()); // support json-encoded bodies app.use(bodyparser.urlencoded({ // support url-encoded bodies extended: true }));
Comments
Post a Comment