I have a web app for travel and tour. The front end is in Angular JS, HTML 5 for front end and Spring boot, MySQL for backend. The backend server is running. The app loads webpage but on Register form when I enter details. and click Register I get an alrt message of fail.Because the Login.js is tyring to send a POST Request.
Below is the Login.js code. The issue is that on clicking the register button I get the following error on console. angular.min.js:103 POST http://localhost:63343/registration 404 (Not Found)
//Controller for login and signup corresponds to Login.html
travelApp.controller("loginController",["$scope","$http","$location","$cookieStore","$route","baseService",function($scope,$http,$location,$cookieStore,$route,baseService){
$scope.loginDetails = {email:"",password:""};
$scope.loginFlag = true;
$scope.registerDetails = {email:"",password:"",firstName:"",lastName:"",userName:""};
$scope.pwCheck=function(){
if($scope.registerDetails.password!=$scope.registerDetails.confirmpassword){
$scope.registerForm.$invalid=true;
$scope.pwMatch=true;
}
};
//Function used to check user credentials
$scope.login = function(){
var request = {
method : 'POST',
url : '/login',
headers : {
'Content-Type' : 'application/json'
},
data : $scope.loginDetails
}
$http(request).then(
function(response) {
$scope.$parent.$$childHead.buttonEnable = false;
//$scope.apply();
baseService.setUserName(response.data.userName);
$cookieStore.put('userId',response.data.id);
//$cookieStore.put('Email',response.data.);
$location.path("/dashboard");
},
function(response){
alert("Invalid UserName or Password");
});
}
//Function used to register
$scope.register = function(){
$scope.registerDetails.userName = $scope.registerDetails.firstName+" "+ $scope.registerDetails.lastName;
var request = {
method : 'POST',
url : '/registration',
headers : {
'Content-Type' : 'application/json'
},
data : $scope.registerDetails
}
$http(request).then(
function(response) {
$route.reload();
alert("Registration is successful");
$location.path("/login");
$route.reload();
},
function(response){
alert("fails");
});
}
}]);
I just have a zip file which I loaded in IntelliJ and IntelliJ was smart enough to install dependencies but the AngularJS framework isnt working properly from angular.min.js because it gives error on POST request from /registration