title: how to handle 401 error unauthorized response from laravel to vue.js
body: <p>I am getting crazy about this.</p>
  
  <p>I have role/permissions control in back-end. when user makes a request from vue.js app, it goes to laravel's middleware to check if it has the access. Let's say it doesn't have the access. so I return 401 status code. Now I can do two things. </p>
  
  <p>1) in every component, where I make http calls, I have try catch and in catch, i catch status code and check if it's 401, then i redirect user to somewhere else or show the popup. But as you think, that's bad to write the same thing(not the same thing sometimes redirect, sometimes popup) in every component's http call's catch </p>
  
  <p>2) I need to handle this in interceptors. but I don't know how. Let's say I made the request. in interceptor, I get 401 error. how do I check if I need to redirect or show the popup? I need the best practice. I don't want each route to have some meta data which tells me if true -make redirect, if false, show the popup. </p>
  
  <p>Is there any better way?</p>