I have a HTTP server written in golang and the client is written in AngularJs. The client will send a POST request to the server with username/password to attempt to register a new account. I want the client to do something depending on the answer of the server. If a user with the requested username already exists I want to stay at the registration site, else I want the client to change the view to something else.
I have the follow code to POST to the server, but how do I tell the client that the request failed?
$scope.register = function(){
var postBody = JSON.stringify({username:$scope.vm.user.username, password:$scope.vm.user.password})
Registration.save(postBody, function(data){
//on success
console.log(data)
//$location.path('/bookingsystem')
});
};