0
votes

i handle response status 401 by the axios interceptors. If i get an 401 response, i try to refresh the jwt token and make the request again. But if i get the 401 response, axios or vuejs print that to the console. Why? I don't print the error to the console in my axios interceptor. How can i disable to print this 401 error?

I would like to print other errors but the errors that i handle in the interceptor (for example the 401 response) i would not like to print that in the console.

Thanks!

2
Browser's tend to log all failed requests to the console, nothing to do with Vue or axios. In Chrome you can disable this by clicking on the cog icon and selecting 'Hide network'. That's a pretty blunt instrument though, it won't just hide the 401 errors that you're handling.skirtle

2 Answers

3
votes

A response with HTTP code 401 is an exception as seen by browser and the browser shows it as an error in console. It is not in your hands to show/hide it.

0
votes

did you try try / catch or catch if you are using promises?

It's hard to say without seeing the code, but I would say, try to wrap your axios request in 'try catch' block and in the catch block decide what to do with the error

try {
    axios.get('/user')
}
catch(error) {
    // do something with the error
}

or

axios.get('/user')
.catch(function (error) {
    // do something with the error
})