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
Post a Comment