Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

193
Visualizações
Is there a way to stop 401 unauthorized from logging to console?

I have a function in Vue.js which sends data to the back-end to log the user in. However in cases where the User doesnt exist it returns an 401 unauthorized. That is ok by me , the problem is that it always seems to be logged into the console. I already know i can handle it but it always logs to the console. Is there a way to stop the web console from logging the 401 unauthorized ?

My function

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

I want to stop this from being logged.

https://ibb.co/6vNdYrw

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can't do that. It's the same as trying to stop requests from showing up in Chrome's Network Tab. It's implemented by the browser and the website does not have control over it.

about 4 years ago · Juan Pablo Isaza Relatório

0

You cannot really block logging responses from requests into browser console.

In your case you have such a flow, that server responds with code 401 when you are sending invalid user details. It should obviously respond with 404 but probably you do not have any control over it.

The solution to this could be to have function, that would evaluate both response.status and response.data and based on response.data process your case further.

Some initial solution:

switch (response.data && response.status) {
  case ('not found' && 401):
    // handle case
    break;

  default:
    break;
 }
       
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda