Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!