Catch 401 with angular get request

I make a request for a service to check if a particular key is present, if any, it returns some data, and if not, it returns 401. I have no control over the service, but I do not want to display 401 in console - this seems unprofessional, since in most cases this key will not exist. Is there a way to catch 401 so it never prints to the console?

I currently have the following: I can check to see if it has 401 status, but I can't catch it so it doesn't print to the console. Is it possible? I don't need a global 401 handler, I just want to catch it for this particular request.

$http.get(url, { withCredentials: true })
        .success(function(data, status, headers, config) {
          result.resolve(data, status, headers, config);
        })
        .error(function(data, status, headers, config) {
          if(status === 401)
          {
            // I can test for a 401 here, but that doesn't seem to help
          }
          result.reject(data);
        });
+4
2

ajax .

- 200 , .

console.clear() , , , "".

+1

, 401, , , [1]. , [2]: Chrome 401 , . - [3], .

, , , , , .

:

[1] HTTP 401 Angular.js

[2] Angular $http

[3] Chrome Developer Tools 404?

0

All Articles