如何隐藏angularjs HTTP请求的错误信息? [英] How to hide error message in angularjs http request?

查看:212
本文介绍了如何隐藏angularjs HTTP请求的错误信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个API,得到的请求有时我会得到EXIF信息,但有时我会得到错误信息 {错误:无EXIF数据} 如何隐藏此错误消息。
在Chrome中,错误的是400(错误请求)

  $ http.get(res.getQNUrl(域,重点,EXIF))
    .success(功能(数据){
        $ scope.imageExifMap [关键] =数据
    })错误(功能(数据,状态,头,配置){})


解决方案

在上面提到的错误信息是特定浏览器。这是一个浏览器的日志记录功能。

那么有它一个解决方法(不是因为它不是一个问题的解决方案)。我不会推荐它,因为它是一个内置的浏览器功能,你正试图从这样做是为了做任务想喝preSS,但如果这是你想要的,然后这里有几种方法去实现它。


  • 使用像这样一个普通的前pression过滤器

    ^(?!。* 404 \\(未找到\\))(?!。* [文件名])


  • 使用像这样的Log滤波器


我没有解释它更是因为已经有一个SO问题,在详细解释这些。

请参阅this SO ,了解关于上述解决方法的详细说明。

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.

这篇关于如何隐藏angularjs HTTP请求的错误信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆