Reputation: 13
I am new to angular js. I am using Mean Stack Method. My controller.js file has the following code:
var myApp = angular.module('myApp',[]);
myApp.controller('MyCtrl',['$scope','$http',function MyCtrl($scope,$http){
console.log("hello from controller");
$http.get('/pointList');
person1 = {
name:'roni',
email:'[email protected]',
};
person2 = {
name:'abhijit',
email:'[email protected]',
};
person3 = {
name: 'amit',
email: '[email protected]',
};
var pointList =[person1,person2,person3];
$scope.pointList = pointList;
}]);
My server.js has the following code
var express = require('express');
var app = express();
app.use(express.static(__dirname +'/public'));
app.post('/pointList',function(req, res){
console.log("Hey ! received get request");
});
app.listen(3000);
console.log("server running on port 3000");
I am unable to receive the get request. Thanks
Upvotes: 0
Views: 4207
Reputation: 23642
You are firing a get
request from front-end while receiving a post
call at backend. Change the app.post
to app.get
app.post('/pointList',function(req, res){
console.log("Hey ! received get request");
});
Upvotes: 1
Reputation: 786
app.get('/pointList',function(req, res){
console.log("Hey ! received get request");
});
try changing to the above
Upvotes: 0