I am making a get request to a service to check whether a certain key present - if it is, it returns some data, and if not, it returns a 401. I do not have control over the service - but I do not want to display the 401 in the console - that seems unprofessional, since in most cases this key won't exist. Is there a way to catch the 401 so it never prints to the console?
Right now I have the following - I can test whether the status is 401, but I cannot catch it prevent it from printing out to the console. Is this possible? I don't want a global handler on 401s, I just want to catch one 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);
});