I need to send emailId as data from angularjs controller to nodejs. I googled it but I didn't get solution, someone please help me.
controller file:
function ManageProductController($http, $scope, $mdDialog, $document, $location, $localStorage)
{
var vm = this;
vm.email = $localStorage.email;
$http({
url: 'http://localhost:7200/api/manage-product',
method: 'GET',
data: {email:vm.email}
}).success(function(res) {
//$scope.productlist = res;
//console.log(res.result);
vm.result=res.result;
//vm.docs=res.docs;
}, function(error) {
console.log(error);
alert('here');
});
}
In the above code I have sent email as data but in node.js file I am not getting in request.
node file:
router.get('/manage-product', function(req, res){
//console.log('I received get request');
console.log(req);
var findProducts = function(db, callback) {
var cursor =db.collection('proInfo').find().toArray(function(err, docs){
if(err){
callback(new Error("Some problem"));
}else{
callback(null,docs);
}
});
};
}
Here I have put console.log(req); but in the body section I am getting only body{} like this.
http://localhost:7200/manage-productGETandPOSTexamples and let know f it works for you.