go - Is it possible to issue a failure to an AngularJS post request, with a Golang server? -


i have http server written in golang , client written in angularjs. client send post request server username/password attempt register new account. want client depending on answer of server. if user requested username exists want stay @ registration site, else want client change view else.

i have follow code post server, how tell client 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')     });      }; 

assuming using $resource create registration can do

registration.save(postbody, function(data, responseheaders){     //on success     console.log(data)     console.log(responseheaders)     //$location.path('/bookingsystem') }, function(httpresponse){     // handle error     console.log(httpresponse) });  

see documentation on $resource more api documentation.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -