[Vuejs]-How do I call a method in vue from a 401 error catch in axios?

3👍

context inside function changes when you use function keyword. Use arrow function to keep the context inside error handler same as parent scope. You are using it on your then handler, that’s why it’s working there.

.catch((error)=>{
    this.errorMessage='Authentication failed';
})

Leave a comment