title: How to get status code from URL
body: <p>Hello I'm new with javascript and AngularJS.This is my function to get the .json from the server (the server returns a JSON):</p>
  
  <pre><code>function getProducts() {
          return $http.get(urlProducts).then(
              //Success
              function(response) {
                  products= response.data.result;
                  return products;
               },
              //Error
              function(response) {
                  //put best way to return an error
                  return something;
              }
          );
      }
  </code></pre>
  
  <p>My question is: <strong>which is the best way to fetch data from the web server</strong>
  I want to know not only if was success the response, also if the status code was 200.</p>
  
  <p>Then I wanna know if was error what I really want to return (I want to show a image with a text : "Not possible connect with the server. Try it again"). But I making the app with Ionic (HTML5, CSS3 and javascript with AngularJS). So... what is the best way to return a error which I wanna show a image with a text taking about that I'm programming in apache cordova.
  Thanks!</p>