How to remove error 401 message from console with Angularjs/Javascript?

Asked

Viewed 466 times

2

I get the following error message on my console:

POST http://localhost:8080/minhaURL 401 (Unauthorized)

I would like to know how to remove this error log from the console, because I’m already giving a visual feedback to the user that he missed something.

Just to put it in context, I am doing a POST with a password, and if it is incorrect, I return a 401.

EDIT:

JS

    requestHandler.authenticate(password).then(function(response){
         console.log('200 ok');
    }).catch(function(err){
         console.log('401 deu erro na validação')
    });

This is the error message I’m referring to:

inserir a descrição da imagem aqui

  • Post code and when it happens.

  • Okay, I’ll post it....

  • I think even if you treat, the error will continue to appear in the Console. The fact of treating does not mean that the error will stop being displayed on the console, but that now the user will get a satisfaction of what happened.

  • I think this is not possible because it is a behavior of the browser and not the Angularjs.

  • I already wondered if it could not be this @Lucascosta.... But then I wondered if someone has a way out...

2 answers

3


There is no way to prevent the exit to the console.

If you want to force the complete cleaning of the log, use

console.clear();

However this will eliminate all lines, not just the last.

0

.catch(function(err, status){
    if (status === 401) return;
    console.log('algo diferente de 401');
});
  • I don’t want to log a different message... I just don’t want to log anything.... I already give the return of something went wrong on the front, for the user

  • @fernandoocf, it is not the case to only remove the console.log or actually you’re looking for something else?

  • I’ll try to post an image for you

  • I want to take this damn line... because as it comes to an input, the user can make mistakes several times and end up filling the console with errors...

  • Not possible. It will appear and "ready", any request with status >= 400 will appear there.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.