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)
{
}
result.reject(data);
});