I am facing an issue with a Vue.js function that sends data to the back-end for user login. When the user doesn't exist, it returns a 401 unauthorized error. While I can handle this error, it keeps getting logged in the console. Is there a way to prevent the web console from logging the 401 unauthorized error?
Here is 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 am looking for a solution to stop this error from being logged.