title: How to get Response after POST in AngularJS?
body: <p>I have java app with API for REST.
  And I make front-end for it. Now I'm working with authorization.</p>
  
  <p>When I make POST request app returns me JSON message like this: 
  If login and pass is right</p>
  
  <pre><code>{
      "result": {
          "token": "shgvojhhsifav37o5a3sebc3if"
      }
  } 
  </code></pre>
  
  <p>And if they are not right: </p>
  
  <pre><code>{
      "error": {
          "code": 10,
          "message": "Incorrect login or password"
      }
  }
  </code></pre>
  
  <p>I can see the response in browser, but can't take it to use in JavaScript code. </p>
  
  <p>And how can I get it and check for next actions.</p>
  
  <p>My JavaScript:</p>
  
  <pre><code>controllers.controller('userAuthCtrl', ['$scope','$http',
    function($scope, $http){
          $http({
              method: 'POST',
              url: '/rest/api/auth/login',
              data: '?login=test&amp;password=passwo3rd',
              headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
          }).
              success(function(data, status, header, config) {
                  console.log(header());
                  console.log(config);
  
                  $scope.dataU = data;
                  $scope.statusU = status;
              }).error(function(data, status, header, config){
                  console.log(header());
                  console.log(config);
              })
  
    }
  ]);
  </code></pre>
  
  <p>My test HTML is easy now. </p>
  
  <pre><code>&lt;div class="testCont" ng-controller="userAuthCtrl"&gt;
  
  &lt;/div&gt; 
  </code></pre>