Rays
Rays

Reputation: 13

Angular JS server responded with a status of 404 (Not Found)

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

Answers (2)

Thalaivar
Thalaivar

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

Coder John
Coder John

Reputation: 786

app.get('/pointList',function(req, res){
    console.log("Hey ! received get request");

});

try changing to the above

Upvotes: 0

Related Questions