How to hide error message in angularjs http request?

心已入冬 提交于 2019-12-11 12:07:22

问题


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){})

回答1:


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.



来源:https://stackoverflow.com/questions/24950551/how-to-hide-error-message-in-angularjs-http-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!