On click of a button I send a post request to express through angularjs. In express' post
, I redirect to another url. But nothing happens.
When I give a non-existing url, in the console I see a 404 error. When I give a correct existing url, it does absolutely nothing. Doesn't show any error either.
The express code:
app.get('/login',function(request,response){ //the file sent when /login is requested
response.sendFile(__dirname+"/staticFolder/view/login.html");
})
app.post('/loginCheck', function(req, res, next) { //called by angular controller when button clicked
res.redirect('http://localhost:4000/'); //supposed to show index.html
});
app.get('/',function(request,response){
response.sendFile(__dirname+"/staticFolder/view/");
})
The controller:
.controller('loginController',function($scope,$http){
$scope.login=""
$scope.password="";
$scope.mysqlError="";
$scope.loginFunc = function(){
$http({
method:'POST',
url:'/loginCheck',
data:{
login: $scope.login,
password: $scope.password
}
})
.then(function successCallback(response) {
if(response.data=='invalid'){
$scope.mysqlError="mysqlError";
}
});
}
})