I am trying simple thing. Make ajax call to node express and do something based on it. I am not being able to access req.body, I mean it is empty when debuggin from node.js side
NODE SIDE. I am using:
app.use(express.bodyParser());
and this is mine test method in express:
app.get('/courses', function(request, response) {
console.log("I have been hit"); //I Am getting here
});
ANGULAR SIDE:
eventsApp.factory('MainConnector', function($http, $q, $resource ) {
return {
mainConnection: function( ) {
var requestBody = {
id: 3,
name: 'testname',
lastname: 'testlastname'
}
$http.get("http://localhost:3000/courses", requestBody)
.success(function(data, status, headers, config) {
console.log("this is coming from wherever:" + data);
$scope.data = data;
}).error(function(data, status, headers, config) {
$scope.status = status;
});
}
};
});
I am trying access (from node side)
req.body.name
But body is always empty, as if I am not sending anything.