有没有办法阻止 401 未经授权登录控制台?

use*_*941 2 javascript vue.js

我在 Vue.js 中有一个函数,它将数据发送到后端以让用户登录。但是,如果用户不存在,它会返回 401 未经授权。这对我来说没问题,问题是它似乎总是登录到控制台。我已经知道我可以处理它,但它总是记录到控制台。有没有办法阻止 Web 控制台记录未经授权的 401?

我的功能

  this.$store
          .dispatch("userLogin", {
            username: this.username,
            password: this.password,
          })
          .then((response) => {
            switch (response.status) {
              case 401:
                //I know unauthorized attempt can be handled here.
                break;
            }
            this.$router.push({ name: "Admin" });
          })
          .catch(function (error) {
            console.log(error.response.data);
          });
      }
Run Code Online (Sandbox Code Playgroud)

我想阻止它被记录。

https://ibb.co/6vNdYrw

小智 5

你不能那样做。这与尝试阻止请求显示在 Chrome 的“网络”选项卡中相同。它是由浏览器实现的,网站无法控制它。