简体   繁体   中英

How to hide error message in angularjs http request?

I have get a request from an API, some times I would get the EXIF information, but sometimes I will get error message {"error":"no exif data"} How can I hide this error message. In chrome, the error is 400 (Bad Request)

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

The error message you mentioned above is browser specific. It is a browser logging functionality.

Well there is a workaround(not a solution since its not a problem) for it. I would not recommend it since its a built-in browser functionality you are trying to suppress from doing the task it is meant to do, but if that is what you want then here are couple of ways to achieve it.

  • Using a regular expression filter like so

    ^(?!.* 404 \\(Not Found\\))(?!.*[file name])

  • Using a Log filter like so

在此处输入图片说明

I have not explained it much because there is already an SO question that explains these in detail.

Please refer this SO for detailed explanation regarding the above mentioned workarounds.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM