• <tfoot id='FjoBO'></tfoot>

    <i id='FjoBO'><tr id='FjoBO'><dt id='FjoBO'><q id='FjoBO'><span id='FjoBO'><b id='FjoBO'><form id='FjoBO'><ins id='FjoBO'></ins><ul id='FjoBO'></ul><sub id='FjoBO'></sub></form><legend id='FjoBO'></legend><bdo id='FjoBO'><pre id='FjoBO'><center id='FjoBO'></center></pre></bdo></b><th id='FjoBO'></th></span></q></dt></tr></i><div id='FjoBO'><tfoot id='FjoBO'></tfoot><dl id='FjoBO'><fieldset id='FjoBO'></fieldset></dl></div>

        <bdo id='FjoBO'></bdo><ul id='FjoBO'></ul>
    1. <legend id='FjoBO'><style id='FjoBO'><dir id='FjoBO'><q id='FjoBO'></q></dir></style></legend>

        <small id='FjoBO'></small><noframes id='FjoBO'>

        在 chrome 开发工具中隐藏 401 console.error 在 fetch(

        时间:2023-10-15
        1. <legend id='NpHmI'><style id='NpHmI'><dir id='NpHmI'><q id='NpHmI'></q></dir></style></legend>

            <small id='NpHmI'></small><noframes id='NpHmI'>

              <bdo id='NpHmI'></bdo><ul id='NpHmI'></ul>
            • <i id='NpHmI'><tr id='NpHmI'><dt id='NpHmI'><q id='NpHmI'><span id='NpHmI'><b id='NpHmI'><form id='NpHmI'><ins id='NpHmI'></ins><ul id='NpHmI'></ul><sub id='NpHmI'></sub></form><legend id='NpHmI'></legend><bdo id='NpHmI'><pre id='NpHmI'><center id='NpHmI'></center></pre></bdo></b><th id='NpHmI'></th></span></q></dt></tr></i><div id='NpHmI'><tfoot id='NpHmI'></tfoot><dl id='NpHmI'><fieldset id='NpHmI'></fieldset></dl></div>
                <tbody id='NpHmI'></tbody>
                <tfoot id='NpHmI'></tfoot>

                  本文介绍了在 chrome 开发工具中隐藏 401 console.error 在 fetch() 调用中得到 401的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有一些代码用于进行 fetch 调用.这利用了现代 chrome/firefox 中内置的 window.fetch api.

                  I have some code where i make a fetch call. This takes advantage of window.fetch api built into modern chrome / firefox.

                  代码有时会遇到 401:unauthorized 响应.这是正常的,我希望它被忽略,我可以通过代码流来做到这一点.但是,当我尝试运行 Chrome 时,它​​会显示难看的 console.error 消息.

                  The code sometimes hits a 401:unauthorized response. This is normal and I want it ignored, which I can do with the flow of the code. However, Chrome does show an unsightly console.error message when I try to run it.

                  如何以编程方式防止此控制台错误显示在所有机器的开发控制台中(即,没有 chrome 开发过滤器或 tampermonkey 类型插件).

                  How can I PROGRAMMATICALLY prevent this console error from showing in the dev console on all machines (i.e., no chrome dev filters or tampermonkey type plugins).

                  这里有一个示例:

                  fetch("http://httpstat.us/401", {requiredStatus: 'ok'})
                      .then(function() {
                          console.log("pass!");
                      }).catch(function() {
                          console.log("fail!");
                      });

                  推荐答案

                  很遗憾,这无法做到,因为控制台中的这种类型的消息是由 chrome 自己打印的.压制这种类型的消息已经争论了多年,但共识似乎是这条消息是可取的 - 查看此讨论.

                  Unfortunately, this cannot be done, as this type of message in the console is printed by chrome itself. Repressing this type of message has been debated for years, but the consensus seems to be that this message is desirable - see this discussion.

                  以防万一您有兴趣:根据 此评论,我们看到此消息的原因是因为对资源检索请求的响应进行了评估,并且消息是在上下文级别调度的.

                  Just in case you're interested: As per this comment, the reason we're seeing this message is because the response to resource retrieval requests is evaluated, and messages are dispatched at the context level.

                  从本质上讲,chrome 的编写方式不允许我们更改此效果,因此我们会收到错误消息.

                  Essentially, the way chrome was written does not allow us to change this effect, and thus we have the error messages.

                  这篇关于在 chrome 开发工具中隐藏 401 console.error 在 fetch() 调用中得到 401的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Javascript:覆盖 XMLHttpRequest.open() 下一篇:“getElementById 不是函数"尝试解析 AJAX 响应时

                  相关文章

                  最新文章

                  1. <legend id='4LzAf'><style id='4LzAf'><dir id='4LzAf'><q id='4LzAf'></q></dir></style></legend>

                      <tfoot id='4LzAf'></tfoot>

                      <small id='4LzAf'></small><noframes id='4LzAf'>

                        <bdo id='4LzAf'></bdo><ul id='4LzAf'></ul>
                    1. <i id='4LzAf'><tr id='4LzAf'><dt id='4LzAf'><q id='4LzAf'><span id='4LzAf'><b id='4LzAf'><form id='4LzAf'><ins id='4LzAf'></ins><ul id='4LzAf'></ul><sub id='4LzAf'></sub></form><legend id='4LzAf'></legend><bdo id='4LzAf'><pre id='4LzAf'><center id='4LzAf'></center></pre></bdo></b><th id='4LzAf'></th></span></q></dt></tr></i><div id='4LzAf'><tfoot id='4LzAf'></tfoot><dl id='4LzAf'><fieldset id='4LzAf'></fieldset></dl></div>