3

GET url 400 (Bad Request) or any get url error. How to ignore the error?

$http.get(res.getQNUrl(domain, key, "exif"))
.success(function(data){
    $scope.imageExifMap[key] = data
}).error(entry.onError)

e.g.: http://tratao-public.qiniudn.com/c851b00c127146997f017bb899bb9bb8.jpg?exif it will get {"error":"no exif data"}

Chrome get error: GET http://tratao-public.qiniudn.com/c851b00c127146997f017bb899bb9bb8.jpg?exif 400 (Bad Request)

lincolnge
  • 1,037
  • 14
  • 19
  • Please provide some code how you send request – Ruben Nagoga Jun 19 '14 at 06:35
  • didn't get the question properly.Why you need to ignore the error – Francis Stalin Jun 19 '14 at 08:06
  • example: `http://qiniuphotos.qiniudn.com/gogopher.jpg?exif`, sometimes the url has not exif, and it would get 400 bad request error. I don't want to get this error. – lincolnge Jun 19 '14 at 08:52
  • Did you manage to solve this issue? – Kiong Oct 15 '15 at 05:22
  • Well, poorly asked. No wonder there is still no answer. What does "ignore the error" means? How could angularjs be used to ignore an error if the error has to happen? And posted twice: http://stackoverflow.com/questions/24950551/how-to-hide-error-message-in-angularjs-http-request :P – Léon Pelletier Nov 10 '15 at 16:53

1 Answers1

-2
var interceptor = ['$rootScope', '$q', "Base64", function (scope, $q, Base64) {
        function success(response) {
            return response;
        }
        function error(response) {
            var status = response.status;
            if (status == 400) {
                window.location = "/account/login?redirectUrl=" + Base64.encode(document.URL);
                return;
            }
            // otherwise
            return $q.reject(response);
        }
        return function (promise) {
            return promise.then(success, error);
        }
    }];

Hope this may help!

Lalit Sachdeva
  • 6,469
  • 2
  • 19
  • 25
  • I don't understand how that is related to the question? It seems to be an interceptor that redirects to a login-page, but why on earth would you do that for a 400 response code? 400 means "Bad Request". – ivarni Jun 19 '14 at 06:47
  • I think the reason is cause he assume you are using a custom interceptor (which causes your issue normally). – Kiong Oct 15 '15 at 05:23